Integrate peer in watcher server and send txs to L2 chain (#344)

* Integrate peer in watcher and send txs to L2

* Remove passing debug log in functions

* Remove unnecessary relay advertise config option

---------

Co-authored-by: prathamesh0 <prathamesh.musale0@gmail.com>
This commit is contained in:
2023-03-24 16:49:16 +04:00
committed by GitHub
co-authored by prathamesh
parent ee63e33cc5
commit ac5e030b13
7 changed files with 60 additions and 19 deletions
+2 -2
View File
@@ -27,7 +27,7 @@ interface Arguments {
}
export class PeerCmd {
async exec (pubSubTopic?: string, parseLibp2pMessage?: (log: debug.Debugger, peerId: string, data: any) => void): Promise<any> {
async exec (pubSubTopic?: string, parseLibp2pMessage?: (peerId: string, data: any) => void): Promise<any> {
const argv: Arguments = _getArgv();
const { Peer } = await import('@cerc-io/peer');
@@ -52,7 +52,7 @@ export class PeerCmd {
if (pubSubTopic) {
peer.subscribeTopic(pubSubTopic, (peerId, data) => {
if (parseLibp2pMessage) {
parseLibp2pMessage(log, peerId.toString(), data);
parseLibp2pMessage(peerId.toString(), data);
} else {
log(`> ${peerId.toString()} > ${data}`);
}
+3 -3
View File
@@ -105,7 +105,7 @@ export class ServerCmd {
async exec (
createResolvers: (indexer: IndexerInterface, eventWatcher: EventWatcher) => Promise<any>,
typeDefs: TypeSource,
parseLibp2pMessage?: (log: debug.Debugger, peerId: string, data: any) => void
parseLibp2pMessage?: (peerId: string, data: any) => void
): Promise<{
app: Application,
server: ApolloServer
@@ -146,7 +146,7 @@ export class ServerCmd {
async _startP2PNodes (
p2pConfig: P2PConfig,
parseLibp2pMessage?: (log: debug.Debugger, peerId: string, data: any) => void
parseLibp2pMessage?: (peerId: string, data: any) => void
): Promise<void> {
const { createRelayNode, Peer } = await import('@cerc-io/peer');
const {
@@ -208,7 +208,7 @@ export class ServerCmd {
peer.subscribeTopic(peerConfig.pubSubTopic, (peerId, data) => {
if (parseLibp2pMessage) {
parseLibp2pMessage(log, peerId.toString(), data);
parseLibp2pMessage(peerId.toString(), data);
}
});