mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-05-05 15:32:15 +00:00
fix: routers should only use dht if enabled (#885)
This commit is contained in:
parent
9941414a91
commit
a34d2bbcc3
@ -35,7 +35,7 @@ class ContentRouting {
|
|||||||
this.dht = libp2p._dht
|
this.dht = libp2p._dht
|
||||||
|
|
||||||
// If we have the dht, add it to the available content routers
|
// If we have the dht, add it to the available content routers
|
||||||
if (this.dht) {
|
if (this.dht && libp2p._config.dht.enabled) {
|
||||||
this.routers.push(this.dht)
|
this.routers.push(this.dht)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class PeerRouting {
|
|||||||
this._routers = libp2p._modules.peerRouting || []
|
this._routers = libp2p._modules.peerRouting || []
|
||||||
|
|
||||||
// If we have the dht, add it to the available peer routers
|
// If we have the dht, add it to the available peer routers
|
||||||
if (libp2p._dht) {
|
if (libp2p._dht && libp2p._config.dht.enabled) {
|
||||||
this._routers.push(libp2p._dht)
|
this._routers.push(libp2p._dht)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,6 +129,10 @@ describe('content-routing', () => {
|
|||||||
|
|
||||||
afterEach(() => node.stop())
|
afterEach(() => node.stop())
|
||||||
|
|
||||||
|
it('should only have one router', () => {
|
||||||
|
expect(node.contentRouting.routers).to.have.lengthOf(1)
|
||||||
|
})
|
||||||
|
|
||||||
it('should use the delegate router to provide', () => {
|
it('should use the delegate router to provide', () => {
|
||||||
const deferred = pDefer()
|
const deferred = pDefer()
|
||||||
|
|
||||||
|
@ -132,6 +132,10 @@ describe('peer-routing', () => {
|
|||||||
|
|
||||||
afterEach(() => node.stop())
|
afterEach(() => node.stop())
|
||||||
|
|
||||||
|
it('should only have one router', () => {
|
||||||
|
expect(node.peerRouting._routers).to.have.lengthOf(1)
|
||||||
|
})
|
||||||
|
|
||||||
it('should use the delegate router to find peers', async () => {
|
it('should use the delegate router to find peers', async () => {
|
||||||
const deferred = pDefer()
|
const deferred = pDefer()
|
||||||
const [remotePeerId] = await peerUtils.createPeerId({ fixture: false })
|
const [remotePeerId] = await peerUtils.createPeerId({ fixture: false })
|
||||||
|
Loading…
x
Reference in New Issue
Block a user