diff --git a/docs/env.md b/docs/env.md index a20500736..9c718177c 100644 --- a/docs/env.md +++ b/docs/env.md @@ -25,6 +25,7 @@ Environmental variables are also tracked in `ENVIRONMENT_VARIABLES` within `src/ - `RATE_DENY_LIST`: Blocked list of IPs and peer IDs. Example: `"{ \"peers\": [\"16Uiu2HAkuYfgjXoGcSSLSpRPD6XtUgV71t5RqmTmcqdbmrWY9MJo\"], \"ips\": [\"127.0.0.1\"] }"` - `MAX_REQ_PER_SECOND`: Number of requests per second allowed by the same client. Example: `3` - `MAX_CHECKSUM_LENGTH`: Define the maximum length for a file if checksum is required (Mb). Example: `10` +- `IS_BOOTSTRAP`: Is this node to be used as bootstrap node or not. Default is `false`. ## Logs diff --git a/src/@types/OceanNode.ts b/src/@types/OceanNode.ts index bc0f9d535..f221a30d8 100644 --- a/src/@types/OceanNode.ts +++ b/src/@types/OceanNode.ts @@ -94,6 +94,7 @@ export interface OceanNodeConfig { rateLimit?: number denyList?: DenyList unsafeURLs?: string[] + isBootstrap?: boolean } export interface P2PStatusResponse { diff --git a/src/components/P2P/index.ts b/src/components/P2P/index.ts index 9e9ec1c79..f8333115d 100644 --- a/src/components/P2P/index.ts +++ b/src/components/P2P/index.ts @@ -124,7 +124,11 @@ export class OceanP2P extends EventEmitter { this._protocol = '/ocean/nodes/1.0.0' // this._interval = setInterval(this._pollPeers.bind(this), this._options.pollInterval) - this._libp2p.handle(this._protocol, handleProtocolCommands.bind(this)) + + // only enable handling of commands if not bootstrap node + if (!this._config.isBootstrap) { + this._libp2p.handle(this._protocol, handleProtocolCommands.bind(this)) + } setInterval(this.republishStoredDDOS.bind(this), REPUBLISH_INTERVAL_HOURS) diff --git a/src/utils/config.ts b/src/utils/config.ts index bc659edcf..c96b4f3ff 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -616,7 +616,8 @@ async function getEnvConfig(isStartup?: boolean): Promise { ENVIRONMENT_VARIABLES.UNSAFE_URLS, isStartup, knownUnsafeURLs - ) + ), + isBootstrap: getBoolEnvValue(process.env.IS_BOOTSTRAP, false) } if (!previousConfiguration) { diff --git a/src/utils/constants.ts b/src/utils/constants.ts index b1acee704..2bf91f761 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -317,6 +317,11 @@ export const ENVIRONMENT_VARIABLES: Record = { name: 'DB_TYPE', value: process.env.DB_TYPE, required: false + }, + IS_BOOTSTRAP: { + name: 'IS_BOOTSTRAP', + value: process.env.IS_BOOTSTRAP, + required: false } }