aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-04-21 02:37:40 +0800
committerobscuren <geffobscura@gmail.com>2015-04-21 02:37:40 +0800
commitb8160cc6d495678815738d46414e77ec89933f16 (patch)
tree439c44ba56d29a94db6775c30fda8a654592ad39
parentf28b2bb6edad287ae418abc7b9ef5e147df84886 (diff)
downloadgo-tangerine-b8160cc6d495678815738d46414e77ec89933f16.tar.gz
go-tangerine-b8160cc6d495678815738d46414e77ec89933f16.tar.zst
go-tangerine-b8160cc6d495678815738d46414e77ec89933f16.zip
core: shuffled some code
-rw-r--r--core/chain_manager.go20
1 files changed, 13 insertions, 7 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go
index 3f2b3a26a..1df56b27f 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -26,11 +26,10 @@ var (
blockNumPre = []byte("block-num-")
)
-const blockCacheLimit = 10000
-
-type StateQuery interface {
- GetAccount(addr []byte) *state.StateObject
-}
+const (
+ blockCacheLimit = 10000
+ maxFutureBlocks = 256
+)
func CalcDifficulty(block, parent *types.Header) *big.Int {
diff := new(big.Int)
@@ -95,7 +94,14 @@ type ChainManager struct {
}
func NewChainManager(blockDb, stateDb common.Database, mux *event.TypeMux) *ChainManager {
- bc := &ChainManager{blockDb: blockDb, stateDb: stateDb, genesisBlock: GenesisBlock(stateDb), eventMux: mux, quit: make(chan struct{}), cache: NewBlockCache(blockCacheLimit)}
+ bc := &ChainManager{
+ blockDb: blockDb,
+ stateDb: stateDb,
+ genesisBlock: GenesisBlock(stateDb),
+ eventMux: mux,
+ quit: make(chan struct{}),
+ cache: NewBlockCache(blockCacheLimit),
+ }
bc.setLastBlock()
// Check the current state of the block hashes and make sure that we do not have any of the bad blocks in our chain
@@ -116,7 +122,7 @@ func NewChainManager(blockDb, stateDb common.Database, mux *event.TypeMux) *Chai
// Take ownership of this particular state
bc.txState = state.ManageState(bc.State().Copy())
- bc.futureBlocks = NewBlockCache(254)
+ bc.futureBlocks = NewBlockCache(maxFutureBlocks)
bc.makeCache()
go bc.update()