Skip to content

Commit 55b60e6

Browse files
committed
core: insert less length zero chains
This reduces the amount of queueEvents that are sent internally.
1 parent e7e2cbf commit 55b60e6

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎core/chain_manager.go‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -522,13 +522,14 @@ type queueEvent struct {
522522
}
523523

524524
func (self *ChainManager) procFutureBlocks() {
525-
blocks := []*types.Block{}
525+
var blocks []*types.Block
526526
self.futureBlocks.Each(func(i int, block *types.Block) {
527527
blocks = append(blocks, block)
528528
})
529-
530-
types.BlockBy(types.Number).Sort(blocks)
531-
self.InsertChain(blocks)
529+
if len(blocks) > 0 {
530+
types.BlockBy(types.Number).Sort(blocks)
531+
self.InsertChain(blocks)
532+
}
532533
}
533534

534535
// InsertChain will attempt to insert the given chain in to the canonical chain or, otherwise, create a fork. It an error is returned

0 commit comments

Comments
 (0)