don't delete under the read lock

let gc clean up the addrs
This commit is contained in:
vyzo 2019-04-28 11:35:23 +03:00
parent 3291020401
commit d0a3cc17f4

View File

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