mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-08 08:54:05 +00:00
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:
@@ -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}`);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user