Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed the force sync cycle #1169

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions eth/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package eth
import (
"math/big"
"math/rand"
"time"

"github.com/dominant-strategies/go-quai/common"
"github.com/dominant-strategies/go-quai/core/types"
Expand All @@ -30,8 +29,7 @@ import (
)

const (
forceSyncCycle = 60 * time.Second // Time interval to force syncs, even if few peers are available
defaultMinSyncPeers = 3 // Amount of peers desired to start syncing
defaultMinSyncPeers = 3 // Amount of peers desired to start syncing

// This is the target size for the packs of transactions sent by txsyncLoop64.
// A pack can get larger than this if a single transactions exceeds this size.
Expand Down Expand Up @@ -154,8 +152,6 @@ func (h *handler) txsyncLoop64() {
// chainSyncer coordinates blockchain sync components.
type chainSyncer struct {
handler *handler
force *time.Timer
forced bool // true when force timer fired
peerEventCh chan struct{}
doneCh chan error // non-nil when sync is running
}
Expand Down Expand Up @@ -201,11 +197,6 @@ func (cs *chainSyncer) loop() {
defer cs.handler.blockFetcher.Stop()
defer cs.handler.downloader.Terminate()

// The force timer lowers the peer count threshold down to one when it fires.
// This ensures we'll always start sync even if there aren't enough peers.
cs.force = time.NewTimer(forceSyncCycle)
defer cs.force.Stop()

for {
if op := cs.nextSyncOp(); op != nil {
cs.startSync(op)
Expand All @@ -215,10 +206,6 @@ func (cs *chainSyncer) loop() {
// Peer information changed, recheck.
case <-cs.doneCh:
cs.doneCh = nil
cs.force.Reset(forceSyncCycle)
cs.forced = false
case <-cs.force.C:
cs.forced = true

case <-cs.handler.quitSync:
// Disable all insertion on the blockchain. This needs to happen before
Expand All @@ -241,9 +228,8 @@ func (cs *chainSyncer) nextSyncOp() *chainSyncOp {

// Ensure we're at minimum peer count.
minPeers := defaultMinSyncPeers
if cs.forced {
minPeers = 1
} else if minPeers > cs.handler.maxPeers {

if minPeers > cs.handler.maxPeers {
minPeers = cs.handler.maxPeers
}
if cs.handler.peers.len() < minPeers {
Expand Down