mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-03-27 04:41:03 +00:00
* fix: not dial all known peers on startup * feat: connection manager should proactively connect to peers from peerStore * chore: increase bundle size * fix: do connMgr proactive dial on an interval * chore: address review * chore: use retimer reschedule * chore: address review * fix: use minConnections in default config * chore: minPeers to minConnections everywhere
70 lines
1.4 KiB
JavaScript
70 lines
1.4 KiB
JavaScript
'use strict'
|
|
|
|
const mergeOptions = require('merge-options')
|
|
const Constants = require('./constants')
|
|
|
|
const { FaultTolerance } = require('./transport-manager')
|
|
|
|
const DefaultConfig = {
|
|
addresses: {
|
|
listen: [],
|
|
announce: [],
|
|
noAnnounce: []
|
|
},
|
|
connectionManager: {
|
|
minConnections: 25
|
|
},
|
|
transportManager: {
|
|
faultTolerance: FaultTolerance.FATAL_ALL
|
|
},
|
|
dialer: {
|
|
maxParallelDials: Constants.MAX_PARALLEL_DIALS,
|
|
maxDialsPerPeer: Constants.MAX_PER_PEER_DIALS,
|
|
dialTimeout: Constants.DIAL_TIMEOUT
|
|
},
|
|
metrics: {
|
|
enabled: false
|
|
},
|
|
peerStore: {
|
|
persistence: false,
|
|
threshold: 5
|
|
},
|
|
config: {
|
|
dht: {
|
|
enabled: false,
|
|
kBucketSize: 20,
|
|
randomWalk: {
|
|
enabled: false, // disabled waiting for https://github.com/libp2p/js-libp2p-kad-dht/issues/86
|
|
queriesPerPeriod: 1,
|
|
interval: 300e3,
|
|
timeout: 10e3
|
|
}
|
|
},
|
|
peerDiscovery: {
|
|
autoDial: true
|
|
},
|
|
pubsub: {
|
|
enabled: true,
|
|
emitSelf: true,
|
|
signMessages: true,
|
|
strictSigning: true
|
|
},
|
|
relay: {
|
|
enabled: true,
|
|
hop: {
|
|
enabled: false,
|
|
active: false
|
|
}
|
|
},
|
|
transport: {}
|
|
}
|
|
}
|
|
|
|
module.exports.validate = (opts) => {
|
|
opts = mergeOptions(DefaultConfig, opts)
|
|
|
|
if (opts.modules.transport.length < 1) throw new Error("'options.modules.transport' must contain at least 1 transport")
|
|
|
|
return opts
|
|
}
|