good morning!!!!

Skip to content
Snippets Groups Projects
Commit 1e965cb8 authored by Jeffrey Wilcke's avatar Jeffrey Wilcke
Browse files

Moved BlockDo to utils

parent fd1ddbce
Branches
Tags
No related merge requests found
...@@ -215,7 +215,7 @@ func (self *JSRE) execBlock(call otto.FunctionCall) otto.Value { ...@@ -215,7 +215,7 @@ func (self *JSRE) execBlock(call otto.FunctionCall) otto.Value {
return otto.UndefinedValue() return otto.UndefinedValue()
} }
err = self.ethereum.BlockDo(ethutil.FromHex(hash)) err = utils.BlockDo(self.ethereum, ethutil.FromHex(hash))
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return otto.FalseValue() return otto.FalseValue()
......
package utils package utils
import ( import (
"fmt"
"github.com/ethereum/eth-go" "github.com/ethereum/eth-go"
"github.com/ethereum/eth-go/ethminer" "github.com/ethereum/eth-go/ethminer"
"github.com/ethereum/eth-go/ethpub" "github.com/ethereum/eth-go/ethpub"
...@@ -74,3 +75,21 @@ func StartMining(ethereum *eth.Ethereum) bool { ...@@ -74,3 +75,21 @@ func StartMining(ethereum *eth.Ethereum) bool {
return false return false
} }
// Replay block
func BlockDo(ethereum *eth.Ethereum, hash []byte) error {
block := ethereum.BlockChain().GetBlock(hash)
if block == nil {
return fmt.Errorf("unknown block %x", hash)
}
parent := ethereum.BlockChain().GetBlock(block.PrevHash)
_, err := ethereum.StateManager().ApplyDiff(parent.State(), parent, block)
if err != nil {
return err
}
return nil
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment