Skip to content

Commit

Permalink
Fix voting process stopping with each synchronization (#90)
Browse files Browse the repository at this point in the history
* Fix nil panic in td.Cmp(bestTd)

* Fix voting process stopping with each synchronization.

RelatedCode:
- eth/downloader/downloader.go#L463
- core/vote/vote_manager.go#L108-L110)
  • Loading branch information
ironbeer authored Oct 31, 2024
1 parent 410f5eb commit 6cb8ad4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion eth/peerset.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ func (ps *peerSet) peerWithHighestJustifiedBlockAndTD() (bestPeer *eth.Peer, bes
continue
}
_, td := p.Head()
if *justified > bestJustified || (*justified == bestJustified && td.Cmp(bestTd) > 0) {
if bestPeer == nil || *justified > bestJustified || (*justified == bestJustified && td.Cmp(bestTd) > 0) {
bestPeer, bestJustified, bestTd = p.Peer, *justified, td
}
}
Expand Down
4 changes: 2 additions & 2 deletions eth/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ func (cs *chainSyncer) nextSyncOp() *chainSyncOp {
if peerJustified < *ourJustified {
return nil
}
// Ignored because justified block height is the same but TD is lower.
if peerJustified == *ourJustified && peerTD.Cmp(ourTD) < 0 {
// Ignored because justified block height is the same but TD is the same or lower.
if peerJustified == *ourJustified && peerTD.Cmp(ourTD) <= 0 {
return nil
}
}
Expand Down

0 comments on commit 6cb8ad4

Please sign in to comment.