From 2c616bd2795974877b0d3e23e99f6eff9e775218 Mon Sep 17 00:00:00 2001 From: zelig Date: Wed, 4 Mar 2015 02:06:15 +0700 Subject: partial fix to idle best peer issue - best peer cannot be idle for more than idleBestPeerTimeout - introduce ErrIdleTooLong fatal error - modify default values --- blockpool/blockpool.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'blockpool/blockpool.go') 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 -- cgit