mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-08 16:54:08 +00:00
Add support for gossipsub (#410)
* Replace floodsub with gossipsub * Add a pubsub flag to support both floodsub and gossipsub * Fix deps * Handle empty string values * Upgrade @cerc-io/libp2p dependency * Upgrade package versions
This commit is contained in:
@@ -51,6 +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
|
||||
* `enable-debug-info`: Whether to broadcast node's info over pubsub on request
|
||||
|
||||
* The process starts reading from `stdin` and outputs messages from others peers over the `/chat/1.0.0` protocol to `stdout`.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cerc-io/cli",
|
||||
"version": "0.2.55",
|
||||
"version": "0.2.56",
|
||||
"main": "dist/index.js",
|
||||
"license": "AGPL-3.0",
|
||||
"scripts": {
|
||||
@@ -12,11 +12,11 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@apollo/client": "^3.7.1",
|
||||
"@cerc-io/cache": "^0.2.55",
|
||||
"@cerc-io/ipld-eth-client": "^0.2.55",
|
||||
"@cerc-io/peer": "^0.2.55",
|
||||
"@cerc-io/rpc-eth-client": "^0.2.55",
|
||||
"@cerc-io/util": "^0.2.55",
|
||||
"@cerc-io/cache": "^0.2.56",
|
||||
"@cerc-io/ipld-eth-client": "^0.2.56",
|
||||
"@cerc-io/peer": "^0.2.56",
|
||||
"@cerc-io/rpc-eth-client": "^0.2.56",
|
||||
"@cerc-io/util": "^0.2.56",
|
||||
"@ethersproject/providers": "^5.4.4",
|
||||
"@graphql-tools/utils": "^9.1.1",
|
||||
"@ipld/dag-cbor": "^8.0.0",
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
PeerIdObj
|
||||
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/49721#issuecomment-1319854183
|
||||
} from '@cerc-io/peer';
|
||||
import { PubsubType } from '@cerc-io/util';
|
||||
|
||||
import { readPeerId } from './utils';
|
||||
|
||||
@@ -26,6 +27,7 @@ interface Arguments {
|
||||
dialTimeout: number;
|
||||
maxRelayConnections: number;
|
||||
peerIdFile: string;
|
||||
pubsub?: PubsubType;
|
||||
enableDebugInfo: boolean;
|
||||
}
|
||||
|
||||
@@ -60,6 +62,7 @@ export class PeerCmd {
|
||||
maxConnections: argv.maxConnections,
|
||||
dialTimeout: argv.dialTimeout,
|
||||
maxRelayConnections: argv.maxRelayConnections,
|
||||
pubsub: argv.pubsub,
|
||||
enableDebugInfo: argv.enableDebugInfo
|
||||
};
|
||||
|
||||
@@ -112,9 +115,13 @@ function _getArgv (): any {
|
||||
alias: 'f',
|
||||
describe: 'Peer id file path (json)'
|
||||
},
|
||||
pubsub: {
|
||||
type: 'string',
|
||||
describe: "Pubsub to use ('floodsub' | 'gossipsub')"
|
||||
},
|
||||
enableDebugInfo: {
|
||||
type: 'boolean',
|
||||
describe: 'Whether to participate in exchanging debug info over floodsub',
|
||||
describe: 'Whether to participate in exchanging debug info over pubsub',
|
||||
default: false
|
||||
}
|
||||
}).argv;
|
||||
|
||||
@@ -187,6 +187,7 @@ export class ServerCmd {
|
||||
redialInterval: relayConfig.redialInterval ?? RELAY_REDIAL_INTERVAL,
|
||||
maxDialRetry: relayConfig.maxDialRetry ?? RELAY_DEFAULT_MAX_DIAL_RETRY,
|
||||
peerIdObj,
|
||||
pubsub: relayConfig.pubsub,
|
||||
enableDebugInfo: relayConfig.enableDebugInfo
|
||||
};
|
||||
await createRelayNode(relayNodeInit);
|
||||
@@ -212,6 +213,7 @@ export class ServerCmd {
|
||||
relayRedialInterval: peerConfig.relayRedialInterval,
|
||||
maxConnections: peerConfig.maxConnections,
|
||||
dialTimeout: peerConfig.dialTimeout,
|
||||
pubsub: peerConfig.pubsub,
|
||||
enableDebugInfo: peerConfig.enableDebugInfo
|
||||
};
|
||||
await this._peer.init(peerNodeInit, peerIdObj);
|
||||
|
||||
Reference in New Issue
Block a user