From 10c7b17c434b670d64e2e9e4fa2e1480c92726ab Mon Sep 17 00:00:00 2001 From: Matheus Degiovani Date: Mon, 23 Oct 2023 12:55:29 -0300 Subject: [PATCH] spv: Remove peer disconnection logic The p2p package already ensures peers are dropped if they are behind the wallet's main chain tip height, therefore this check is redundant in the spv syncer. --- spv/sync.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/spv/sync.go b/spv/sync.go index 63593c446..7ef679dd9 100644 --- a/spv/sync.go +++ b/spv/sync.go @@ -1495,6 +1495,9 @@ func (s *Syncer) getHeaders(ctx context.Context, rp *p2p.RemotePeer) error { s.sidechainMu.Unlock() + // Any new peers should not be significantly behind the new tip. + s.setRequiredHeight(int32(tip.Header.Height)) + // Generate new locators s.locatorMu.Lock() locators, err = s.wallet.BlockLocators(ctx, nil) @@ -1509,13 +1512,6 @@ func (s *Syncer) getHeaders(ctx context.Context, rp *p2p.RemotePeer) error { } func (s *Syncer) startupSync(ctx context.Context, rp *p2p.RemotePeer) error { - // Disconnect from the peer if their advertised block height is - // significantly behind the wallet's. - _, tipHeight := s.wallet.MainChainTip(ctx) - if rp.InitialHeight() < tipHeight-6 { - return errors.E("peer is not synced") - } - // Continue with fetching headers only after missing cfilters have // been fetched. select {