diff options
author | obscuren <geffobscura@gmail.com> | 2014-04-29 18:36:27 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-04-29 18:36:27 +0800 |
commit | 38d6b67b5cfbfb63620a244ea01b5b534917128f (patch) | |
tree | 42b4f55e4cd5c2f2a2c28f8551d8b92686abf567 /ethchain | |
parent | 5516efdfa0494e028fc3649e4a38da81c56ed598 (diff) | |
download | dexon-38d6b67b5cfbfb63620a244ea01b5b534917128f.tar dexon-38d6b67b5cfbfb63620a244ea01b5b534917128f.tar.gz dexon-38d6b67b5cfbfb63620a244ea01b5b534917128f.tar.bz2 dexon-38d6b67b5cfbfb63620a244ea01b5b534917128f.tar.lz dexon-38d6b67b5cfbfb63620a244ea01b5b534917128f.tar.xz dexon-38d6b67b5cfbfb63620a244ea01b5b534917128f.tar.zst dexon-38d6b67b5cfbfb63620a244ea01b5b534917128f.zip |
Fixed state problem
Diffstat (limited to 'ethchain')
-rw-r--r-- | ethchain/block.go | 5 | ||||
-rw-r--r-- | ethchain/block_chain.go | 3 | ||||
-rw-r--r-- | ethchain/state_manager.go | 13 |
3 files changed, 10 insertions, 11 deletions
diff --git a/ethchain/block.go b/ethchain/block.go index d95ebf4b5..aac50ccb1 100644 --- a/ethchain/block.go +++ b/ethchain/block.go @@ -80,9 +80,6 @@ func CreateBlock(root interface{}, extra string, txes []*Transaction) *Block { - // Copy over the bytes - copiedRoot := ethutil.NewValue(root).Bytes() - block := &Block{ // Slice of transactions to include in this block transactions: txes, @@ -98,7 +95,7 @@ func CreateBlock(root interface{}, block.SetTransactions(txes) block.SetUncles([]*Block{}) - block.state = NewState(ethutil.NewTrie(ethutil.Config.Db, copiedRoot)) + block.state = NewState(ethutil.NewTrie(ethutil.Config.Db, root)) for _, tx := range txes { block.MakeContract(tx) diff --git a/ethchain/block_chain.go b/ethchain/block_chain.go index 08886c9cd..2be4cd92b 100644 --- a/ethchain/block_chain.go +++ b/ethchain/block_chain.go @@ -179,7 +179,8 @@ func (bc *BlockChain) ResetTillBlockHash(hash []byte) error { bc.LastBlockNumber = info.Number } - bc.Ethereum.StateManager().PrepareDefault(returnTo) + // XXX Why are we resetting? This is the block chain, it has nothing to do with states + //bc.Ethereum.StateManager().PrepareDefault(returnTo) err := ethutil.Config.Db.Delete(lastBlock.Hash()) if err != nil { diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go index 628ab6a27..70d4155c3 100644 --- a/ethchain/state_manager.go +++ b/ethchain/state_manager.go @@ -158,18 +158,19 @@ func (sm *StateManager) ProcessBlock(block *Block, dontReact bool) error { // Processing a blocks may never happen simultaneously sm.mutex.Lock() defer sm.mutex.Unlock() - // Defer the Undo on the Trie. If the block processing happened - // we don't want to undo but since undo only happens on dirty - // nodes this won't happen because Commit would have been called - // before that. - defer sm.bc.CurrentBlock.Undo() hash := block.Hash() if sm.bc.HasBlock(hash) { - fmt.Println("[SM] We already have this block, ignoring") + fmt.Println("[STATE] We already have this block, ignoring") return nil } + // Defer the Undo on the Trie. If the block processing happened + // we don't want to undo but since undo only happens on dirty + // nodes this won't happen because Commit would have been called + // before that. + defer sm.bc.CurrentBlock.Undo() + // Check if we have the parent hash, if it isn't known we discard it // Reasons might be catching up or simply an invalid block if !sm.bc.HasBlock(block.PrevHash) && sm.bc.CurrentBlock != nil { |