mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-03-16 15:40:49 +00:00
fix: dht configuration selectors and validators (#919)
This commit is contained in:
parent
6456a0fff8
commit
cc1f4af879
@ -56,6 +56,9 @@ const { updateSelfPeerRecord } = require('./record/utils')
|
||||
* @property {MuxedStream} stream
|
||||
* @property {string} protocol
|
||||
*
|
||||
* @typedef {{ [key: string]: function (Uint8Array, Uint8Array[]): number }} DhtSelectors
|
||||
* @typedef {{ [key: string]: { func: (key: Uint8Array, value: Uint8Array) => Promise<void> }}} DhtValidators
|
||||
*
|
||||
* @typedef {Object} RandomWalkOptions
|
||||
* @property {boolean} [enabled = false]
|
||||
* @property {number} [queriesPerPeriod = 1]
|
||||
@ -67,6 +70,8 @@ const { updateSelfPeerRecord } = require('./record/utils')
|
||||
* @property {number} [kBucketSize = 20]
|
||||
* @property {RandomWalkOptions} [randomWalk]
|
||||
* @property {boolean} [clientMode]
|
||||
* @property {DhtSelectors} [selectors]
|
||||
* @property {DhtValidators} [validators]
|
||||
*
|
||||
* @typedef {Object} KeychainOptions
|
||||
* @property {Datastore} [datastore]
|
||||
|
@ -13,6 +13,7 @@
|
||||
"libp2p-kad-dht": "^0.21.0",
|
||||
"libp2p-mplex": "^0.10.2",
|
||||
"libp2p-noise": "^2.0.5",
|
||||
"libp2p-record": "^0.10.2",
|
||||
"libp2p-tcp": "^0.15.3",
|
||||
"libp2p-websockets": "^0.15.3",
|
||||
"peer-id": "^0.14.3"
|
||||
|
@ -1,4 +1,5 @@
|
||||
import Libp2p = require('libp2p')
|
||||
import Libp2pRecord = require('libp2p-record')
|
||||
|
||||
const TCP = require('libp2p-tcp')
|
||||
const WEBSOCKETS = require('libp2p-websockets')
|
||||
@ -22,6 +23,7 @@ const DelegatedPeerRouter = require('libp2p-delegated-peer-routing')
|
||||
const DelegatedContentRouter = require('libp2p-delegated-content-routing')
|
||||
const PeerId = require('peer-id')
|
||||
|
||||
|
||||
// Known peers addresses
|
||||
const bootstrapMultiaddrs = [
|
||||
'/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb',
|
||||
@ -125,6 +127,13 @@ async function main() {
|
||||
enabled: true, // Allows to disable discovery (enabled by default)
|
||||
interval: 300e3,
|
||||
timeout: 10e3
|
||||
},
|
||||
clientMode: true,
|
||||
validators: {
|
||||
pk: Libp2pRecord.validator.validators.pk
|
||||
},
|
||||
selectors: {
|
||||
pk: Libp2pRecord.selection.selectors.pk
|
||||
}
|
||||
},
|
||||
nat: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user