diff options
author | zelig <viktor.tron@gmail.com> | 2015-03-25 19:09:50 +0800 |
---|---|---|
committer | zelig <viktor.tron@gmail.com> | 2015-03-25 20:11:29 +0800 |
commit | 9d592c0445aa8bb85921225a9cdc4ca1d4df85d3 (patch) | |
tree | d567abc67c854165af9a58e0adb81b78480e48e1 /blockpool/peers.go | |
parent | 6431d088ad511a8250741a531fd137592e687fc7 (diff) | |
download | go-tangerine-9d592c0445aa8bb85921225a9cdc4ca1d4df85d3.tar.gz go-tangerine-9d592c0445aa8bb85921225a9cdc4ca1d4df85d3.tar.zst go-tangerine-9d592c0445aa8bb85921225a9cdc4ca1d4df85d3.zip |
bugfix with idle too long triggered after peer switch
- reset bestIdleTimer when launching head section process
- log chain head events
- common.Hash key in activateChain map
Diffstat (limited to 'blockpool/peers.go')
-rw-r--r-- | blockpool/peers.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/blockpool/peers.go b/blockpool/peers.go index 1e56f315d..615058e26 100644 --- a/blockpool/peers.go +++ b/blockpool/peers.go @@ -356,16 +356,16 @@ func (self *BlockPool) switchPeer(oldp, newp *peer) { } - var connected = make(map[string]*section) + var connected = make(map[common.Hash]*section) var sections []common.Hash for _, hash := range newp.sections { plog.DebugDetailf("activate chain starting from section [%s]", hex(hash)) // if section not connected (ie, top of a contiguous sequence of sections) - if connected[hash.Str()] == nil { + if connected[hash] == nil { // if not deleted, then reread from pool (it can be orphaned top half of a split section) if entry := self.get(hash); entry != nil { self.activateChain(entry.section, newp, connected) - connected[hash.Str()] = entry.section + connected[hash] = entry.section sections = append(sections, hash) } } @@ -531,6 +531,7 @@ func (self *peer) run() { self.blocksRequestTimer = time.After(0) self.headInfoTimer = time.After(self.bp.Config.BlockHashesTimeout) + self.bestIdleTimer = nil var ping = time.NewTicker(5 * time.Second) @@ -581,7 +582,7 @@ LOOP: case <-self.bp.quit: break LOOP - // quit + // best case <-self.bestIdleTimer: self.peerError(self.bp.peers.errors.New(ErrIdleTooLong, "timed out without providing new blocks (td: %v, head: %s)...quitting", self.td, hex(self.currentBlockHash))) |