Skip to content

Commit

Permalink
Do not create syncer if already at stopnode
Browse files Browse the repository at this point in the history
  • Loading branch information
gammazero committed Mar 28, 2024
1 parent 75aff3a commit cb742f1
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions dagsync/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,15 +857,6 @@ func (h *handler) asyncSyncAdChain(ctx context.Context) {

// Get the latest pending message.
amsg := h.pendingMsg.Swap(nil)
peerInfo := peer.AddrInfo{
ID: amsg.PeerID,
Addrs: amsg.Addrs,
}
syncer, updatePeerstore, err := h.makeSyncer(peerInfo, true)
if err != nil {
log.Errorw("Cannot make syncer for announce", "err", err, "peer", h.peerID)
return
}

adsDepthLimit := h.subscriber.adsDepthLimit
nextCid := amsg.Cid
Expand All @@ -882,6 +873,15 @@ func (h *handler) asyncSyncAdChain(ctx context.Context) {
adsDepthLimit = recursionLimit(h.subscriber.firstSyncDepth)
}

peerInfo := peer.AddrInfo{
ID: amsg.PeerID,
Addrs: amsg.Addrs,
}
syncer, updatePeerstore, err := h.makeSyncer(peerInfo, true)
if err != nil {
log.Errorw("Cannot make syncer for announce", "err", err, "peer", h.peerID)
return
}
sel := ExploreRecursiveWithStopNode(adsDepthLimit, h.subscriber.adsSelectorSeq, latestSyncLink)
syncCount, err := h.handle(ctx, nextCid, sel, syncer, h.subscriber.generalBlockHook, h.subscriber.segDepthLimit, stopAtCid)
if err != nil {
Expand Down

0 comments on commit cb742f1

Please sign in to comment.