Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

have bootstrap config var #782

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading