core: insert less length zero chains

This reduces the amount of queueEvents that are sent internally.
This commit is contained in:
Felix Lange 2015-05-29 18:55:42 +02:00
parent e7e2cbfc01
commit 55b60e699b
1 changed files with 5 additions and 4 deletions

View File

@ -522,13 +522,14 @@ type queueEvent struct {
}
func (self *ChainManager) procFutureBlocks() {
blocks := []*types.Block{}
var blocks []*types.Block
self.futureBlocks.Each(func(i int, block *types.Block) {
blocks = append(blocks, block)
})
types.BlockBy(types.Number).Sort(blocks)
self.InsertChain(blocks)
if len(blocks) > 0 {
types.BlockBy(types.Number).Sort(blocks)
self.InsertChain(blocks)
}
}
// InsertChain will attempt to insert the given chain in to the canonical chain or, otherwise, create a fork. It an error is returned