File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,11 @@ const (
2929 // more.
3030 minInFlightBlocks = 10
3131
32+ // minSyncPeerMedianHeights is the minimum number of valid sync
33+ // peer candidates to trust for updating the sync peer due
34+ // to it being behind.
35+ minSyncPeerMedianHeights = 5
36+
3237 // maxNetworkViolations is the max number of network violations a
3338 // sync peer can have before a new sync peer is found.
3439 maxNetworkViolations = 3
@@ -579,9 +584,9 @@ func (sm *SyncManager) medianSyncPeerCandidateBlockHeight() int32 {
579584 heights = append (heights , topBlock )
580585 }
581586
582- // If we don't have any sync peer candidate heights, return 0 .
583- // This is just to protect from a panic below.
584- if len (heights ) < 1 {
587+ // Make sure we have enough heights to trust the data .
588+ // If we only have 1 or 2 that could be gamed easily!
589+ if len (heights ) < minSyncPeerMedianHeights {
585590 return 0
586591 }
587592
You can’t perform that action at this time.
0 commit comments