mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 12:46:44 +00:00
set lastMissing count to depth, so that a reinitialised section connected to the blockchain triggers insertChain even if section completes - wow
This commit is contained in:
parent
5720bc6e2f
commit
1278173372
1 changed files with 12 additions and 17 deletions
|
|
@ -585,7 +585,7 @@ func (self *BlockPool) processSection(section *section, nodes []*poolNode) {
|
||||||
// container for missing block hashes
|
// container for missing block hashes
|
||||||
var hashes [][]byte
|
var hashes [][]byte
|
||||||
|
|
||||||
var i, total, missing, lastMissing, depth int
|
var i, missing, lastMissing, depth int
|
||||||
var idle int
|
var idle int
|
||||||
var init, done, same, ready bool
|
var init, done, same, ready bool
|
||||||
var insertChain bool
|
var insertChain bool
|
||||||
|
|
@ -622,14 +622,14 @@ func (self *BlockPool) processSection(section *section, nodes []*poolNode) {
|
||||||
// went through all blocks in section
|
// went through all blocks in section
|
||||||
if missing == 0 {
|
if missing == 0 {
|
||||||
// no missing blocks
|
// no missing blocks
|
||||||
poolLogger.Debugf("[%s] got all blocks. process complete (%v total blocksRequests): missing %v/%v/%v", sectionName(section), blocksRequests, missing, total, depth)
|
poolLogger.Debugf("[%s] got all blocks. process complete (%v total blocksRequests): missing %v/%v/%v", sectionName(section), blocksRequests, missing, lastMissing, depth)
|
||||||
blocksRequestsComplete = true
|
blocksRequestsComplete = true
|
||||||
blocksRequestTimer = nil
|
blocksRequestTimer = nil
|
||||||
blocksRequestTime = false
|
blocksRequestTime = false
|
||||||
} else {
|
} else {
|
||||||
// some missing blocks
|
// some missing blocks
|
||||||
blocksRequests++
|
blocksRequests++
|
||||||
poolLogger.Debugf("[%s] block request attempt %v: missing %v/%v/%v", sectionName(section), blocksRequests, missing, total, depth)
|
poolLogger.Debugf("[%s] block request attempt %v: missing %v/%v/%v", sectionName(section), blocksRequests, missing, lastMissing, depth)
|
||||||
if len(hashes) > 0 {
|
if len(hashes) > 0 {
|
||||||
// send block requests to peers
|
// send block requests to peers
|
||||||
self.requestBlocks(blocksRequests, hashes)
|
self.requestBlocks(blocksRequests, hashes)
|
||||||
|
|
@ -643,7 +643,7 @@ func (self *BlockPool) processSection(section *section, nodes []*poolNode) {
|
||||||
idle++
|
idle++
|
||||||
// too many idle rounds
|
// too many idle rounds
|
||||||
if idle >= blocksRequestMaxIdleRounds {
|
if idle >= blocksRequestMaxIdleRounds {
|
||||||
poolLogger.Debugf("[%s] block requests had %v idle rounds (%v total attempts): missing %v/%v/%v\ngiving up...", sectionName(section), idle, blocksRequests, missing, total, depth)
|
poolLogger.Debugf("[%s] block requests had %v idle rounds (%v total attempts): missing %v/%v/%v\ngiving up...", sectionName(section), idle, blocksRequests, missing, lastMissing, depth)
|
||||||
close(section.suicideC)
|
close(section.suicideC)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -668,7 +668,7 @@ func (self *BlockPool) processSection(section *section, nodes []*poolNode) {
|
||||||
//
|
//
|
||||||
|
|
||||||
if ready && blocksRequestTime && !blocksRequestsComplete {
|
if ready && blocksRequestTime && !blocksRequestsComplete {
|
||||||
poolLogger.Debugf("[%s] check if new blocks arrived (attempt %v): missing %v/%v/%v", sectionName(section), blocksRequests, missing, total, depth)
|
poolLogger.Debugf("[%s] check if new blocks arrived (attempt %v): missing %v/%v/%v", sectionName(section), blocksRequests, missing, lastMissing, depth)
|
||||||
blocksRequestTimer = time.After(blocksRequestInterval * time.Millisecond)
|
blocksRequestTimer = time.After(blocksRequestInterval * time.Millisecond)
|
||||||
blocksRequestTime = false
|
blocksRequestTime = false
|
||||||
processC = offC
|
processC = offC
|
||||||
|
|
@ -710,7 +710,7 @@ func (self *BlockPool) processSection(section *section, nodes []*poolNode) {
|
||||||
|
|
||||||
case <-suicideTimer:
|
case <-suicideTimer:
|
||||||
close(section.suicideC)
|
close(section.suicideC)
|
||||||
poolLogger.Debugf("[%s] timeout. (%v total attempts): missing %v/%v/%v", sectionName(section), blocksRequests, missing, total, depth)
|
poolLogger.Debugf("[%s] timeout. (%v total attempts): missing %v/%v/%v", sectionName(section), blocksRequests, missing, lastMissing, depth)
|
||||||
|
|
||||||
case <-section.suicideC:
|
case <-section.suicideC:
|
||||||
poolLogger.Debugf("[%s] suicide", sectionName(section))
|
poolLogger.Debugf("[%s] suicide", sectionName(section))
|
||||||
|
|
@ -744,7 +744,7 @@ func (self *BlockPool) processSection(section *section, nodes []*poolNode) {
|
||||||
self.procWg.Done()
|
self.procWg.Done()
|
||||||
poolLogger.Debugf("[%s] idle mode", sectionName(section))
|
poolLogger.Debugf("[%s] idle mode", sectionName(section))
|
||||||
if init {
|
if init {
|
||||||
poolLogger.Debugf("[%s] off (%v total attempts): missing %v/%v/%v", sectionName(section), blocksRequests, missing, total, depth)
|
poolLogger.Debugf("[%s] off (%v total attempts): missing %v/%v/%v", sectionName(section), blocksRequests, missing, lastMissing, depth)
|
||||||
}
|
}
|
||||||
|
|
||||||
blocksRequestTime = false
|
blocksRequestTime = false
|
||||||
|
|
@ -777,12 +777,10 @@ func (self *BlockPool) processSection(section *section, nodes []*poolNode) {
|
||||||
poolLogger.Debugf("[%s] initialise section", sectionName(section))
|
poolLogger.Debugf("[%s] initialise section", sectionName(section))
|
||||||
i = 0
|
i = 0
|
||||||
missing = 0
|
missing = 0
|
||||||
total = 0
|
|
||||||
lastMissing = 0
|
|
||||||
depth = 0
|
|
||||||
self.wg.Add(1)
|
self.wg.Add(1)
|
||||||
self.procWg.Add(1)
|
self.procWg.Add(1)
|
||||||
depth = len(section.nodes)
|
depth = len(section.nodes)
|
||||||
|
lastMissing = depth
|
||||||
// if not run at least once fully, launch iterator
|
// if not run at least once fully, launch iterator
|
||||||
go func() {
|
go func() {
|
||||||
var node *poolNode
|
var node *poolNode
|
||||||
|
|
@ -824,10 +822,7 @@ func (self *BlockPool) processSection(section *section, nodes []*poolNode) {
|
||||||
init = true
|
init = true
|
||||||
done = true
|
done = true
|
||||||
processC = make(chan *poolNode, missing)
|
processC = make(chan *poolNode, missing)
|
||||||
|
poolLogger.Debugf("[%s] section initalised: missing %v/%v/%v", sectionName(section), missing, lastMissing, depth)
|
||||||
total = missing
|
|
||||||
|
|
||||||
poolLogger.Debugf("[%s] section initalised: missing %v/%v/%v", sectionName(section), missing, total, depth)
|
|
||||||
continue LOOP
|
continue LOOP
|
||||||
}
|
}
|
||||||
if ready {
|
if ready {
|
||||||
|
|
@ -857,8 +852,8 @@ func (self *BlockPool) processSection(section *section, nodes []*poolNode) {
|
||||||
insertChain = true
|
insertChain = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
poolLogger.Debugf("[%s] %v/%v/%v/%v", sectionName(section), i, missing, total, depth)
|
poolLogger.Debugf("[%s] %v/%v/%v/%v", sectionName(section), i, missing, lastMissing, depth)
|
||||||
if i == lastMissing {
|
if i == lastMissing && init {
|
||||||
poolLogger.Debugf("[%s] done", sectionName(section))
|
poolLogger.Debugf("[%s] done", sectionName(section))
|
||||||
done = true
|
done = true
|
||||||
}
|
}
|
||||||
|
|
@ -880,7 +875,7 @@ func (self *BlockPool) processSection(section *section, nodes []*poolNode) {
|
||||||
|
|
||||||
} // select
|
} // select
|
||||||
} // for
|
} // for
|
||||||
poolLogger.Debugf("[%s] quit: %v block hashes requests - %v block requests - missing %v/%v/%v", sectionName(section), blockHashesRequests, blocksRequests, missing, total, depth)
|
poolLogger.Debugf("[%s] quit: %v block hashes requests - %v block requests - missing %v/%v/%v", sectionName(section), blockHashesRequests, blocksRequests, missing, lastMissing, depth)
|
||||||
|
|
||||||
close(section.offC)
|
close(section.offC)
|
||||||
poolLogger.Debugf("[%s] process complete", sectionName(section))
|
poolLogger.Debugf("[%s] process complete", sectionName(section))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue