Skip to content

Commit

Permalink
feat: stop syninc and exit when near bad block
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenvechain committed Jun 5, 2024
1 parent fce0a17 commit d8353da
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions comm/communicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"math"
"sort"
"sync"
"syscall"
"time"

"github.com/ethereum/go-ethereum/event"
Expand Down Expand Up @@ -94,6 +95,14 @@ func (c *Communicator) Sync(ctx context.Context, handler HandleBlockStream) {
log.Debug("synchronization start")

best := c.repo.BestBlockSummary().Header

if best.Number() > 13800000 {
// we are near to problematic block, so let's force an exit
log.Warn("synchronization done, best assumed")
syscall.Kill(syscall.Getpid(), syscall.SIGINT)
break
}

// choose peer which has the head block with higher total score
peer := c.peerSet.Slice().Find(func(peer *Peer) bool {
_, totalScore := peer.Head()
Expand Down

0 comments on commit d8353da

Please sign in to comment.