forked from cerc-io/plugeth
Fixed state problem
This commit is contained in:
+1
-4
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -158,17 +158,18 @@ func (sm *StateManager) ProcessBlock(block *Block, dontReact bool) error {
|
||||
// Processing a blocks may never happen simultaneously
|
||||
sm.mutex.Lock()
|
||||
defer sm.mutex.Unlock()
|
||||
hash := block.Hash()
|
||||
|
||||
if sm.bc.HasBlock(hash) {
|
||||
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()
|
||||
hash := block.Hash()
|
||||
|
||||
if sm.bc.HasBlock(hash) {
|
||||
fmt.Println("[SM] We already have this block, ignoring")
|
||||
return nil
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user