aboutsummaryrefslogtreecommitdiffstats
path: root/blockpool/blockpool.go
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-03-25 19:09:50 +0800
committerzelig <viktor.tron@gmail.com>2015-03-25 20:11:29 +0800
commit9d592c0445aa8bb85921225a9cdc4ca1d4df85d3 (patch)
treed567abc67c854165af9a58e0adb81b78480e48e1 /blockpool/blockpool.go
parent6431d088ad511a8250741a531fd137592e687fc7 (diff)
downloaddexon-9d592c0445aa8bb85921225a9cdc4ca1d4df85d3.tar.gz
dexon-9d592c0445aa8bb85921225a9cdc4ca1d4df85d3.tar.zst
dexon-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/blockpool.go')
-rw-r--r--blockpool/blockpool.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/blockpool/blockpool.go b/blockpool/blockpool.go
index 1ca97e0ca..46eac3549 100644
--- a/blockpool/blockpool.go
+++ b/blockpool/blockpool.go
@@ -238,12 +238,13 @@ func (self *BlockPool) Start() {
case event := <-self.tdSub.Chan():
if ev, ok := event.(core.ChainHeadEvent); ok {
td := ev.Block.Td
- plog.DebugDetailf("td: %v", td)
+ plog.DebugDetailf("ChainHeadEvent: height: %v, td: %v, hash: %s", ev.Block.Number(), td, hex(ev.Block.Hash()))
self.setTD(td)
self.peers.lock.Lock()
if best := self.peers.best; best != nil {
- if td.Cmp(best.td) >= 0 {
+ // only switch if we strictly go above otherwise we may stall if only
+ if td.Cmp(best.td) > 0 {
self.peers.best = nil
self.switchPeer(best, nil)
}
@@ -706,7 +707,7 @@ func (self *BlockPool) AddBlock(block *types.Block, peerId string) {
It activates the section process on incomplete sections with peer.
It relinks orphaned sections with their parent if root block (and its parent hash) is known.
*/
-func (self *BlockPool) activateChain(sec *section, p *peer, connected map[string]*section) {
+func (self *BlockPool) activateChain(sec *section, p *peer, connected map[common.Hash]*section) {
p.lock.RLock()
switchC := p.switchC
@@ -720,7 +721,7 @@ LOOP:
plog.DebugDetailf("activateChain: section [%s] activated by peer <%s>", sectionhex(sec), p.id)
sec.activate(p)
if i > 0 && connected != nil {
- connected[sec.top.hash.Str()] = sec
+ connected[sec.top.hash] = sec
}
/*
Need to relink both complete and incomplete sections