Skip to content

Commit

Permalink
Merge pull request #782 from oceanprotocol/issue-781-disable-cmd
Browse files Browse the repository at this point in the history
have bootstrap config var
  • Loading branch information
paulo-ocean authored Dec 5, 2024
2 parents 8e1cbe2 + e7360da commit ab4547b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/@types/OceanNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export interface OceanNodeConfig {
rateLimit?: number
denyList?: DenyList
unsafeURLs?: string[]
isBootstrap?: boolean
}

export interface P2PStatusResponse {
Expand Down
6 changes: 5 additions & 1 deletion src/components/P2P/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,8 @@ async function getEnvConfig(isStartup?: boolean): Promise<OceanNodeConfig> {
ENVIRONMENT_VARIABLES.UNSAFE_URLS,
isStartup,
knownUnsafeURLs
)
),
isBootstrap: getBoolEnvValue(process.env.IS_BOOTSTRAP, false)
}

if (!previousConfiguration) {
Expand Down
5 changes: 5 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@ export const ENVIRONMENT_VARIABLES: Record<any, EnvVariable> = {
name: 'DB_TYPE',
value: process.env.DB_TYPE,
required: false
},
IS_BOOTSTRAP: {
name: 'IS_BOOTSTRAP',
value: process.env.IS_BOOTSTRAP,
required: false
}
}

Expand Down

0 comments on commit ab4547b

Please sign in to comment.