From 1d9f076fcbaffb7b4afff7d7c8db6f40aeeafe57 Mon Sep 17 00:00:00 2001 From: JoeGruff Date: Tue, 29 Oct 2024 10:56:37 +0900 Subject: [PATCH] spv: Accept cfilters from more peers. If initial sync takes longer than six blocks and peers have not changed, sync will hand at ninety-nine percent unable to get cfilters for the last few blocks. Also accept cfilters from a peer that gave us headers at or above the desired height in this case. --- spv/backend.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spv/backend.go b/spv/backend.go index ca6ff64c1..5859344e3 100644 --- a/spv/backend.go +++ b/spv/backend.go @@ -52,8 +52,10 @@ func pickForGetCfilters(lastHeaderHeight int32) func(rp *p2p.RemotePeer) bool { // blocks are generated while performing the sync, therefore // the initial advertised peer height would be lower than the // last header height. Therefore, accept peers that are - // close, but not quite at the tip. - return rp.InitialHeight() >= lastHeaderHeight-6 + // close, but not quite at the tip. It's possible that sync + // until now took longer than six blocks. In that case get + // cfilters from a peer that gave us headers. + return rp.InitialHeight() >= lastHeaderHeight-6 || rp.LastHeight() >= lastHeaderHeight } }