Skip to content

Commit

Permalink
Clean peer info at subscriber exported API
Browse files Browse the repository at this point in the history
  • Loading branch information
masih committed Feb 14, 2024
1 parent 820dced commit 5eedcbc
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions dagsync/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ func (s *Subscriber) SyncAdChain(ctx context.Context, peerInfo peer.AddrInfo, op
opts.blockHook = s.generalBlockHook
}

peerInfo = cleanPeerAddrInfo(peerInfo)
var err error
peerInfo, err = removeIDFromAddrs(peerInfo)
if err != nil {
Expand Down Expand Up @@ -563,6 +564,7 @@ func (s *Subscriber) syncEntries(ctx context.Context, peerInfo peer.AddrInfo, en
s.expSyncMutex.Unlock()
defer s.expSyncWG.Done()

peerInfo = cleanPeerAddrInfo(peerInfo)
peerInfo, err := removeIDFromAddrs(peerInfo)
if err != nil {
return err
Expand Down Expand Up @@ -1089,3 +1091,14 @@ SegSyncLoop:
log.Debugw("Segmented sync completed", "syncedCount", syncedCount)
return syncedCount, nil
}

func cleanPeerAddrInfo(target peer.AddrInfo) peer.AddrInfo {
var cleaned peer.AddrInfo
cleaned.Addrs = make([]multiaddr.Multiaddr, 0, len(target.Addrs))
for _, addr := range target.Addrs {
if addr != nil {
cleaned.Addrs = append(cleaned.Addrs, addr)
}
}
return cleaned
}

0 comments on commit 5eedcbc

Please sign in to comment.