mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-08 16:54:08 +00:00
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:
@@ -43,7 +43,7 @@ A basic CLI to pass messages between peers using `stdin`/`stdout`
|
||||
|
||||
```bash
|
||||
# In packages/cli
|
||||
yarn chat --relay-multiaddr <RELAY_MULTIADDR> --max-connections [MAX_CONNECTIONS] --dial-timeout [DIAL_TIMEOUT] --max-relay-connections [MAX_RELAY_CONNECTIONS] --peer-id-file [PEER_ID_FILE_PATH]
|
||||
yarn chat --relay-multiaddr <RELAY_MULTIADDR> --max-connections [MAX_CONNECTIONS] --dial-timeout [DIAL_TIMEOUT] --max-relay-connections [MAX_RELAY_CONNECTIONS] --peer-id-file [PEER_ID_FILE_PATH] --enable-debug-info [ENABLE_DEBUG_INFO]
|
||||
```
|
||||
|
||||
* `relay-multiaddr (r)`: multiaddr of a primary hop enabled relay node
|
||||
@@ -51,5 +51,6 @@ A basic CLI to pass messages between peers using `stdin`/`stdout`
|
||||
* `dial-timeout`: timeout for dial to peers (ms)
|
||||
* `max-relay-connections`: max number of relay node connections for this peer
|
||||
* `peer-id-file (f)`: file path for peer id to be used (json)
|
||||
* `enable-debug-info`: Whether to broadcast node's info over floodsub on request
|
||||
|
||||
* The process starts reading from `stdin` and outputs messages from others peers over the `/chat/1.0.0` protocol to `stdout`.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user