Browse Source

Merge pull request #1194 from tendermint/1177-semantics-of-currate-low-msg

improve "curRate too low" message
pull/1201/head
Ethan Buchman 7 years ago
committed by GitHub
parent
commit
cf1e1f5899
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 4 deletions
  1. +14
    -4
      blockchain/pool.go

+ 14
- 4
blockchain/pool.go View File

@ -1,6 +1,7 @@
package blockchain
import (
"fmt"
"math"
"sync"
"time"
@ -30,7 +31,14 @@ const (
maxTotalRequesters = 1000
maxPendingRequests = maxTotalRequesters
maxPendingRequestsPerPeer = 50
minRecvRate = 10240 // 10Kb/s
// Minimum recv rate to ensure we're receiving blocks from a peer fast
// enough. If a peer is not sending us data at at least that rate, we
// consider them to have timedout and we disconnect.
//
// Assuming a DSL connection (not a good choice) 128 Kbps (upload) ~ 15 KB/s,
// sending data across atlantic ~ 7.5 KB/s.
minRecvRate = 7680
)
var peerTimeoutSeconds = time.Duration(15) // not const so we can override with tests
@ -88,7 +96,6 @@ func (pool *BlockPool) OnStop() {}
// Run spawns requesters as needed.
func (pool *BlockPool) makeRequestersRoutine() {
for {
if !pool.IsRunning() {
break
@ -119,10 +126,13 @@ func (pool *BlockPool) removeTimedoutPeers() {
for _, peer := range pool.peers {
if !peer.didTimeout && peer.numPending > 0 {
curRate := peer.recvMonitor.Status().CurRate
// XXX remove curRate != 0
// curRate can be 0 on start
if curRate != 0 && curRate < minRecvRate {
pool.sendTimeout(peer.id)
pool.Logger.Error("SendTimeout", "peer", peer.id, "reason", "curRate too low")
pool.Logger.Error("SendTimeout", "peer", peer.id,
"reason", "peer is not sending us data fast enough",
"curRate", fmt.Sprintf("%d KB/s", curRate/1024),
"minRate", fmt.Sprintf("%d KB/s", minRecvRate/1024))
peer.didTimeout = true
}
}


Loading…
Cancel
Save