mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 02:40:45 +00:00
core: handle future block more elegantly, close XFN-101 (#1672)
This commit is contained in:
parent
aecb6ff7dc
commit
717610c0d8
1 changed files with 7 additions and 2 deletions
|
|
@ -1192,7 +1192,11 @@ func (bc *BlockChain) insertStopped() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bc *BlockChain) procFutureBlocks() {
|
func (bc *BlockChain) procFutureBlocks() {
|
||||||
blocks := make([]*types.Block, 0, bc.futureBlocks.Len())
|
capacity := bc.futureBlocks.Len()
|
||||||
|
if capacity == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
blocks := make([]*types.Block, 0, capacity)
|
||||||
for _, hash := range bc.futureBlocks.Keys() {
|
for _, hash := range bc.futureBlocks.Keys() {
|
||||||
if block, exist := bc.futureBlocks.Peek(hash); exist {
|
if block, exist := bc.futureBlocks.Peek(hash); exist {
|
||||||
blocks = append(blocks, block)
|
blocks = append(blocks, block)
|
||||||
|
|
@ -2572,8 +2576,9 @@ func (bc *BlockChain) PostChainEvents(events []interface{}, logs []*types.Log) {
|
||||||
func (bc *BlockChain) futureBlocksLoop() {
|
func (bc *BlockChain) futureBlocksLoop() {
|
||||||
defer bc.wg.Done()
|
defer bc.wg.Done()
|
||||||
|
|
||||||
futureTimer := time.NewTicker(10 * time.Millisecond)
|
futureTimer := time.NewTicker(100 * time.Millisecond)
|
||||||
defer futureTimer.Stop()
|
defer futureTimer.Stop()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-futureTimer.C:
|
case <-futureTimer.C:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue