faster duplicate check in AddrStream

This commit is contained in:
Steven Allen 2017-12-05 17:38:43 -08:00
parent eaa5f7e9e7
commit dd7efed6ee

View File

@ -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