8000 chore: blocksync improv settings by czarcas7ic · Pull Request #2532 · cometbft/cometbft · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore: blocksync improv settings #2532

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

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file 8000
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion internal/blocksync/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ const (
maxPendingRequestsPerPeer = 20
requestRetrySeconds = 30

// peerConnWait is the time that must have elapsed since the pool routine
// was created before we start making requests. This is to give the peer
// routine time to connect to peers.
peerConnWait = 3 * time.Second

// Minimum recv rate to ensure we're receiving blocks from a peer fast
// enough. If a peer is not sending us data at least that rate, we consider
// them to have timed out, and we disconnect.
Expand Down Expand Up @@ -113,6 +118,14 @@ func (pool *BlockPool) makeRequestersRoutine() {
break
}

// Check if we are within peerConnWait seconds of start time
// This gives us some time to connect to peers before starting a wave of requests
if time.Since(pool.startTime) < peerConnWait {
// Calculate the duration to sleep until peerConnWait seconds have passed since pool.startTime
sleepDuration := peerConnWait - time.Since(pool.startTime)
time.Sleep(sleepDuration)
}

_, numPending, lenRequesters := pool.GetStatus()
switch {
case numPending >= maxPendingRequests:
Expand Down Expand Up @@ -573,7 +586,7 @@ func (peer *bpPeer) onTimeout() {

//-------------------------------------

const minBlocksForSingleRequest = 30
const minBlocksForSingleRequest = 50

// bpRequester requests a block from a peer.
//
Expand Down
0