Skip to content

Commit aba901e

Browse files
committed
core: removed write's go routine
1 parent 07db098 commit aba901e

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

core/chain_makers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func ExampleGenerateChain() {
6060
evmux := &event.TypeMux{}
6161
chainman, _ := NewChainManager(genesis, db, db, FakePow{}, evmux)
6262
chainman.SetProcessor(NewBlockProcessor(db, db, FakePow{}, chainman, evmux))
63-
if i, err := chainman.InsertChain(chain); err != nil {
63+
if i, err := chainman.InsertChain(chain[1:]); err != nil {
6464
fmt.Printf("insert error (block %d): %v\n", i, err)
6565
return
6666
}

core/chain_manager.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/ethereum/go-ethereum/pow"
2323
"github.com/ethereum/go-ethereum/rlp"
2424
"github.com/hashicorp/golang-lru"
25+
"github.com/rcrowley/go-metrics"
2526
"github.com/syndtr/goleveldb/leveldb"
2627
)
2728

@@ -263,9 +264,7 @@ func (bc *ChainManager) setLastState() {
263264
func (bc *ChainManager) makeCache() {
264265
bc.cache, _ = lru.New(blockCacheLimit)
265266
// 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) {
269268
bc.cache.Add(block.Hash(), block)
270269
}
271270
}
@@ -571,9 +570,6 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
571570
defer close(nonceQuit)
572571
defer self.flushQueuedBlocks()
573572

574-
defer func() {
575-
}()
576-
577573
txcount := 0
578574
for i, block := range chain {
579575
if atomic.LoadInt32(&self.procInterrupt) == 1 {
@@ -683,7 +679,6 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
683679
queue[i] = ChainSideEvent{block, logs}
684680
queueEvent.sideCount++
685681
}
686-
// not in the canonical chain.
687682
self.enqueueForWrite(block)
688683
// Delete from future blocks
689684
self.futureBlocks.Delete(block.Hash())

0 commit comments

Comments
 (0)