aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2015-06-24 23:05:23 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-06-30 00:51:49 +0800
commitaba901e13cc40400b644041044ada13636927f44 (patch)
tree0212fedbfa4339ceb2f7f3fe01f9d27f505ed9a0 /core
parent07db098ccf94ebfa80a9dedea85b4f55ad6f8d76 (diff)
downloaddexon-aba901e13cc40400b644041044ada13636927f44.tar
dexon-aba901e13cc40400b644041044ada13636927f44.tar.gz
dexon-aba901e13cc40400b644041044ada13636927f44.tar.bz2
dexon-aba901e13cc40400b644041044ada13636927f44.tar.lz
dexon-aba901e13cc40400b644041044ada13636927f44.tar.xz
dexon-aba901e13cc40400b644041044ada13636927f44.tar.zst
dexon-aba901e13cc40400b644041044ada13636927f44.zip
core: removed write's go routine
Diffstat (limited to 'core')
-rw-r--r--core/chain_makers_test.go2
-rw-r--r--core/chain_manager.go9
2 files changed, 3 insertions, 8 deletions
diff --git a/core/chain_makers_test.go b/core/chain_makers_test.go
index d5125e1c3..8e821fc4a 100644
--- a/core/chain_makers_test.go
+++ b/core/chain_makers_test.go
@@ -60,7 +60,7 @@ func ExampleGenerateChain() {
evmux := &event.TypeMux{}
chainman, _ := NewChainManager(genesis, db, db, FakePow{}, evmux)
chainman.SetProcessor(NewBlockProcessor(db, db, FakePow{}, chainman, evmux))
- if i, err := chainman.InsertChain(chain); err != nil {
+ if i, err := chainman.InsertChain(chain[1:]); err != nil {
fmt.Printf("insert error (block %d): %v\n", i, err)
return
}
diff --git a/core/chain_manager.go b/core/chain_manager.go
index e8f4d9b5b..85c1e39d7 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -22,6 +22,7 @@ import (
"github.com/ethereum/go-ethereum/pow"
"github.com/ethereum/go-ethereum/rlp"
"github.com/hashicorp/golang-lru"
+ "github.com/rcrowley/go-metrics"
"github.com/syndtr/goleveldb/leveldb"
)
@@ -263,9 +264,7 @@ func (bc *ChainManager) setLastState() {
func (bc *ChainManager) makeCache() {
bc.cache, _ = lru.New(blockCacheLimit)
// load in last `blockCacheLimit` - 1 blocks. Last block is the current.
- ancestors := bc.GetAncestors(bc.currentBlock, blockCacheLimit-1)
- ancestors = append(ancestors, bc.currentBlock)
- for _, block := range ancestors {
+ for _, block := range bc.GetBlocksFromHash(bc.currentBlock.Hash(), blockCacheLimit) {
bc.cache.Add(block.Hash(), block)
}
}
@@ -571,9 +570,6 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
defer close(nonceQuit)
defer self.flushQueuedBlocks()
- defer func() {
- }()
-
txcount := 0
for i, block := range chain {
if atomic.LoadInt32(&self.procInterrupt) == 1 {
@@ -683,7 +679,6 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
queue[i] = ChainSideEvent{block, logs}
queueEvent.sideCount++
}
- // not in the canonical chain.
self.enqueueForWrite(block)
// Delete from future blocks
self.futureBlocks.Delete(block.Hash())