Skip to content

Commit

Permalink
Do not create syncer if already at stopnode (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
gammazero authored Mar 28, 2024
1 parent 69d23c7 commit c028218
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions dagsync/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -846,16 +846,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 @@ -872,6 +862,16 @@ 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 c028218

Please sign in to comment.