mirror of
https://github.com/libp2p/go-libp2p-peerstore.git
synced 2024-12-27 23:40:16 +08:00
don't delete under the read lock
let gc clean up the addrs
This commit is contained in:
parent
3291020401
commit
d0a3cc17f4
@ -188,11 +188,9 @@ func (mab *memoryAddrBook) Addrs(p peer.ID) []ma.Multiaddr {
|
||||
|
||||
now := time.Now()
|
||||
good := make([]ma.Multiaddr, 0, len(amap))
|
||||
for k, m := range amap {
|
||||
for _, m := range amap {
|
||||
if !m.ExpiredBy(now) {
|
||||
good = append(good, m.Addr)
|
||||
} else {
|
||||
delete(amap, k)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user