Broadcast peer info over floodsub when requested (#332)

* Refactor discovery handler

* Broadcast peer info over floodsub on requests

* Broadcast peer info from relay nodes

* Make debug reponse handler optional

* Register debug info request handler on peer init

* Move debug info types to types dir

* Return method to unsubscribe from the debug topic

* Make debug info flag optional for relay nodes

* Restructure peer connection info data

* Refactor getting peer info to be used in react app

* Refactor duplicate code to utils

* Rename peer methods

---------

Co-authored-by: nabarun <nabarun@deepstacksoft.com>
This commit is contained in:
prathamesh0
2023-03-06 10:20:51 +05:30
committed by GitHub
co-authored by nabarun
parent 0400546996
commit c46d5c3f33
11 changed files with 332 additions and 31 deletions
+8 -1
View File
@@ -23,6 +23,7 @@ interface Arguments {
dialTimeout: number;
maxRelayConnections: number;
peerIdFile: string;
enableDebugInfo: boolean;
}
export class PeerCmd {
@@ -40,7 +41,8 @@ export class PeerCmd {
const peerNodeInit: PeerInitConfig = {
maxConnections: argv.maxConnections,
dialTimeout: argv.dialTimeout,
maxRelayConnections: argv.maxRelayConnections
maxRelayConnections: argv.maxRelayConnections,
enableDebugInfo: argv.enableDebugInfo
};
await peer.init(peerNodeInit, peerIdObj);
@@ -87,6 +89,11 @@ function _getArgv (): any {
type: 'string',
alias: 'f',
describe: 'Peer id file path (json)'
},
enableDebugInfo: {
type: 'boolean',
describe: 'Whether to participate in exchanging debug info over floodsub',
default: false
}
}).argv;
}
+4 -2
View File
@@ -177,7 +177,8 @@ export class ServerCmd {
pingInterval: relayConfig.pingInterval ?? DEFAULT_PING_INTERVAL,
redialInterval: relayConfig.redialInterval ?? RELAY_REDIAL_INTERVAL,
maxDialRetry: relayConfig.maxDialRetry ?? RELAY_DEFAULT_MAX_DIAL_RETRY,
peerIdObj
peerIdObj,
enableDebugInfo: relayConfig.enableDebugInfo
};
await createRelayNode(relayNodeInit);
}
@@ -200,7 +201,8 @@ export class ServerCmd {
maxRelayConnections: peerConfig.maxRelayConnections,
relayRedialInterval: peerConfig.relayRedialInterval,
maxConnections: peerConfig.maxConnections,
dialTimeout: peerConfig.dialTimeout
dialTimeout: peerConfig.dialTimeout,
enableDebugInfo: peerConfig.enableDebugInfo
};
await peer.init(peerNodeInit, peerIdObj);