@@ -22,6 +22,7 @@ import (
22
22
"github.com/ethereum/go-ethereum/pow"
23
23
"github.com/ethereum/go-ethereum/rlp"
24
24
"github.com/hashicorp/golang-lru"
25
+ "github.com/rcrowley/go-metrics"
25
26
"github.com/syndtr/goleveldb/leveldb"
26
27
)
27
28
@@ -263,9 +264,7 @@ func (bc *ChainManager) setLastState() {
263
264
func (bc * ChainManager ) makeCache () {
264
265
bc .cache , _ = lru .New (blockCacheLimit )
265
266
// load in last `blockCacheLimit` - 1 blocks. Last block is the current.
266
- ancestors := bc .GetAncestors (bc .currentBlock , blockCacheLimit - 1 )
267
- ancestors = append (ancestors , bc .currentBlock )
268
- for _ , block := range ancestors {
267
+ for _ , block := range bc .GetBlocksFromHash (bc .currentBlock .Hash (), blockCacheLimit ) {
269
268
bc .cache .Add (block .Hash (), block )
270
269
}
271
270
}
@@ -571,9 +570,6 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
571
570
defer close (nonceQuit )
572
571
defer self .flushQueuedBlocks ()
573
572
574
- defer func () {
575
- }()
576
-
577
573
txcount := 0
578
574
for i , block := range chain {
579
575
if atomic .LoadInt32 (& self .procInterrupt ) == 1 {
@@ -683,7 +679,6 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
683
679
queue [i ] = ChainSideEvent {block , logs }
684
680
queueEvent .sideCount ++
685
681
}
686
- // not in the canonical chain.
687
682
self .enqueueForWrite (block )
688
683
// Delete from future blocks
689
684
self .futureBlocks .Delete (block .Hash ())
0 commit comments