mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-07-08 21:31:32 +00:00
Compare commits
1 Commits
v0.29.0-rc
...
fix/protoc
Author | SHA1 | Date | |
---|---|---|---|
10d7212373 |
@ -132,19 +132,16 @@ class PeerStore extends EventEmitter {
|
|||||||
multiaddrs: recorded.multiaddrs.toArray()
|
multiaddrs: recorded.multiaddrs.toArray()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update protocols
|
let isProtocolsChanged = false
|
||||||
// TODO: better track added and removed protocols
|
for (const protocol of peerInfo.protocols) {
|
||||||
const protocolsIntersection = new Set(
|
if (!recorded.protocols.has(protocol)) {
|
||||||
[...recorded.protocols].filter((p) => peerInfo.protocols.has(p))
|
isProtocolsChanged = true
|
||||||
)
|
|
||||||
|
|
||||||
if (protocolsIntersection.size !== peerInfo.protocols.size ||
|
|
||||||
protocolsIntersection.size !== recorded.protocols.size) {
|
|
||||||
for (const protocol of peerInfo.protocols) {
|
|
||||||
recorded.protocols.add(protocol)
|
recorded.protocols.add(protocol)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isProtocolsChanged) {
|
||||||
this.emit('change:protocols', {
|
this.emit('change:protocols', {
|
||||||
peerInfo: recorded,
|
peerInfo: recorded,
|
||||||
protocols: Array.from(recorded.protocols)
|
protocols: Array.from(recorded.protocols)
|
||||||
|
Reference in New Issue
Block a user