From bcf9245095f770be0e0216a3a13c5dda87ec144f Mon Sep 17 00:00:00 2001 From: gammazero Date: Thu, 28 Mar 2024 05:04:37 -0700 Subject: [PATCH] Do not create syncer if already at stponode --- dagsync/subscriber.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/dagsync/subscriber.go b/dagsync/subscriber.go index 466d287..4170ad9 100644 --- a/dagsync/subscriber.go +++ b/dagsync/subscriber.go @@ -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 @@ -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 {