mirror of
https://github.com/libp2p/go-libp2p-peerstore.git
synced 2024-12-28 23:50:12 +08:00
faster duplicate check in AddrStream
This commit is contained in:
parent
eaa5f7e9e7
commit
dd7efed6ee
@ -281,7 +281,7 @@ func (mgr *AddrManager) AddrStream(ctx context.Context, p peer.ID) <-chan ma.Mul
|
||||
var outch chan ma.Multiaddr
|
||||
|
||||
for _, a := range buffer {
|
||||
sent[a.String()] = true
|
||||
sent[string(a.Bytes())] = true
|
||||
}
|
||||
|
||||
var next ma.Multiaddr
|
||||
@ -302,11 +302,11 @@ func (mgr *AddrManager) AddrStream(ctx context.Context, p peer.ID) <-chan ma.Mul
|
||||
next = nil
|
||||
}
|
||||
case naddr := <-sub.pubch:
|
||||
if sent[naddr.String()] {
|
||||
if sent[string(naddr.Bytes())] {
|
||||
continue
|
||||
}
|
||||
|
||||
sent[naddr.String()] = true
|
||||
sent[string(naddr.Bytes())] = true
|
||||
if next == nil {
|
||||
next = naddr
|
||||
outch = out
|
||||
|
Loading…
Reference in New Issue
Block a user