Skip to content

Commit 7def785

Browse files
JoeGruffinsjrick
authored andcommitted
[release-v2.0] 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. Backport of 1d9f076.
1 parent 3bbc778 commit 7def785

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

spv/backend.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ func pickForGetCfilters(lastHeaderHeight int32) func(rp *p2p.RemotePeer) bool {
5252
// blocks are generated while performing the sync, therefore
5353
// the initial advertised peer height would be lower than the
5454
// last header height. Therefore, accept peers that are
55-
// close, but not quite at the tip.
56-
return rp.InitialHeight() >= lastHeaderHeight-6
55+
// close, but not quite at the tip. It's possible that sync
56+
// until now took longer than six blocks. In that case get
57+
// cfilters from a peer that gave us headers.
58+
return rp.InitialHeight() >= lastHeaderHeight-6 || rp.LastHeight() >= lastHeaderHeight
5759
}
5860
}
5961

0 commit comments

Comments
 (0)