Skip to content

Commit

Permalink
chore: remove network option we don't want to expose
Browse files Browse the repository at this point in the history
Signed-off-by: Sacha Froment <[email protected]>
  • Loading branch information
sfroment committed Feb 5, 2025
1 parent 044fd7b commit 3565b61
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 43 deletions.
7 changes: 1 addition & 6 deletions configs/e2e-bootstrap.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
"listen_addresses": ["/ip4/0.0.0.0/tcp/50000/ws", "/ip4/0.0.0.0/tcp/50001"],
"bootstrap": true,
"bootstrap_peers": [],
"private_key_seed": "bootstrap",
"pubsub": {
"peer_discovery_interval": 1000,
"prune_backoff": 10,
"heartbeat_interval": 10
}
"private_key_seed": "bootstrap"
}
}
22 changes: 1 addition & 21 deletions examples/grid/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,8 @@ import { getColorForPeerId } from "./util/color";
export function getNetworkConfigFromEnv() {
const hasBootstrapPeers = Boolean(import.meta.env.VITE_BOOTSTRAP_PEERS);
const hasDiscoveryInterval = Boolean(import.meta.env.VITE_DISCOVERY_INTERVAL);
const hasPubsubPruneBackoff = Boolean(import.meta.env.VITE_PUBSUB_PRUNE_BACKOFF);
const hasPubsubHeartbeatInterval = Boolean(import.meta.env.VITE_PUBSUB_HEARTBEAT_INTERVAL);

const hasEnv =
hasBootstrapPeers ||
hasDiscoveryInterval ||
hasPubsubPruneBackoff ||
hasPubsubHeartbeatInterval;
const hasEnv = hasBootstrapPeers || hasDiscoveryInterval;

const config: Record<string, unknown> = {
browser_metrics: true,
Expand All @@ -35,20 +29,6 @@ export function getNetworkConfigFromEnv() {
};
}

if (hasPubsubPruneBackoff) {
config.pubsub = {
...(config.pubsub || {}),
prune_backoff: import.meta.env.VITE_PUBSUB_PRUNE_BACKOFF,
};
}

if (hasPubsubHeartbeatInterval) {
config.pubsub = {
...(config.pubsub || {}),
heartbeat_interval: import.meta.env.VITE_PUBSUB_HEARTBEAT_INTERVAL,
};
}

return config;
}

Expand Down
2 changes: 0 additions & 2 deletions examples/grid/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ interface ImportMetaEnv {
readonly VITE_BOOTSTRAP_PEERS: string;
readonly VITE_DISCOVERY_INTERVAL: number;
readonly VITE_RENDER_INFO_INTERVAL: number;
readonly VITE_PUBSUB_PRUNE_BACKOFF: number;
readonly VITE_PUBSUB_HEARTBEAT_INTERVAL: number;
}

interface ImportMeta {
Expand Down
14 changes: 0 additions & 14 deletions packages/network/src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ export interface DRPNetworkNodeConfig {
private_key_seed?: string;
pubsub?: {
peer_discovery_interval?: number;
prune_backoff?: number;
heartbeat_interval?: number;
};
}

Expand Down Expand Up @@ -119,12 +117,6 @@ export class DRPNetworkNode {
pubsub: gossipsub({
doPX: true,
allowPublishToZeroTopicPeers: true,
...(this._config?.pubsub?.prune_backoff
? { pruneBackoff: this._config.pubsub.prune_backoff }
: {}),
...(this._config?.pubsub?.heartbeat_interval
? { heartbeatInterval: this._config.pubsub.heartbeat_interval }
: {}),
scoreParams: createPeerScoreParams({
IPColocationFactorWeight: 0,
appSpecificScore: (peerId: string) => {
Expand Down Expand Up @@ -156,12 +148,6 @@ export class DRPNetworkNode {
doPX: true,
ignoreDuplicatePublishError: true,
allowPublishToZeroTopicPeers: true,
...(this._config?.pubsub?.prune_backoff
? { pruneBackoff: this._config.pubsub.prune_backoff }
: {}),
...(this._config?.pubsub?.heartbeat_interval
? { heartbeatInterval: this._config.pubsub.heartbeat_interval }
: {}),
scoreParams: createPeerScoreParams({
topicScoreCap: 50,
IPColocationFactorWeight: 0,
Expand Down

0 comments on commit 3565b61

Please sign in to comment.