From 1e965cb8f5c63d73a5aac1556a2638345ba2824c Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 25 Jun 2014 09:47:11 +0200 Subject: Moved BlockDo to utils --- utils/cmd.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'utils') diff --git a/utils/cmd.go b/utils/cmd.go index e66bb2612..368f2381e 100644 --- a/utils/cmd.go +++ b/utils/cmd.go @@ -1,6 +1,7 @@ package utils import ( + "fmt" "github.com/ethereum/eth-go" "github.com/ethereum/eth-go/ethminer" "github.com/ethereum/eth-go/ethpub" @@ -74,3 +75,21 @@ func StartMining(ethereum *eth.Ethereum) bool { 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 + +} -- cgit v1.2.3