aboutsummaryrefslogtreecommitdiffstats
path: root/blockpool/blockpool.go
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-03-04 03:06:15 +0800
committerzelig <viktor.tron@gmail.com>2015-03-04 03:06:15 +0800
commit2c616bd2795974877b0d3e23e99f6eff9e775218 (patch)
tree66dc8e84eddc5295d483a6ca2f577eead37102d2 /blockpool/blockpool.go
parent47278a6e4eb4b8dc02ff322ba24c9c225267ffe5 (diff)
downloadgo-tangerine-2c616bd2795974877b0d3e23e99f6eff9e775218.tar
go-tangerine-2c616bd2795974877b0d3e23e99f6eff9e775218.tar.gz
go-tangerine-2c616bd2795974877b0d3e23e99f6eff9e775218.tar.bz2
go-tangerine-2c616bd2795974877b0d3e23e99f6eff9e775218.tar.lz
go-tangerine-2c616bd2795974877b0d3e23e99f6eff9e775218.tar.xz
go-tangerine-2c616bd2795974877b0d3e23e99f6eff9e775218.tar.zst
go-tangerine-2c616bd2795974877b0d3e23e99f6eff9e775218.zip
partial fix to idle best peer issue
- best peer cannot be idle for more than idleBestPeerTimeout - introduce ErrIdleTooLong fatal error - modify default values
Diffstat (limited to 'blockpool/blockpool.go')
-rw-r--r--blockpool/blockpool.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/blockpool/blockpool.go b/blockpool/blockpool.go
index 5da671ec2..eb3b415dc 100644
--- a/blockpool/blockpool.go
+++ b/blockpool/blockpool.go
@@ -17,7 +17,7 @@ var plog = ethlogger.NewLogger("Blockpool")
var (
// max number of block hashes sent in one request
- blockHashesBatchSize = 512
+ blockHashesBatchSize = 256
// max number of blocks sent in one request
blockBatchSize = 64
// interval between two consecutive block checks (and requests)
@@ -27,11 +27,13 @@ var (
// interval between two consecutive block hash checks (and requests)
blockHashesRequestInterval = 3 * time.Second
// max number of idle iterations, ie., check through a section without new blocks coming in
- blocksRequestMaxIdleRounds = 100
+ blocksRequestMaxIdleRounds = 20
// timeout interval: max time allowed for peer without sending a block hash
blockHashesTimeout = 60 * time.Second
// timeout interval: max time allowed for peer without sending a block
- blocksTimeout = 120 * time.Second
+ blocksTimeout = 60 * time.Second
+ //
+ idleBestPeerTimeout = 60 * time.Second
)
// config embedded in components, by default fall back to constants
@@ -45,6 +47,7 @@ type Config struct {
BlocksRequestInterval time.Duration
BlockHashesTimeout time.Duration
BlocksTimeout time.Duration
+ IdleBestPeerTimeout time.Duration
}
// blockpool errors
@@ -53,6 +56,7 @@ const (
ErrInvalidPoW
ErrUnrequestedBlock
ErrInsufficientChainInfo
+ ErrIdleTooLong
)
var errorToString = map[int]string{
@@ -60,6 +64,7 @@ var errorToString = map[int]string{
ErrInvalidPoW: "Invalid PoW",
ErrUnrequestedBlock: "Unrequested block",
ErrInsufficientChainInfo: "Insufficient chain info",
+ ErrIdleTooLong: "Idle too long",
}
// init initialises all your laundry
@@ -88,6 +93,9 @@ func (self *Config) init() {
if self.BlocksTimeout == 0 {
self.BlocksTimeout = blocksTimeout
}
+ if self.IdleBestPeerTimeout == 0 {
+ self.IdleBestPeerTimeout = idleBestPeerTimeout
+ }
}
// node is the basic unit of the internal model of block chain/tree in the blockpool