aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-06-25 15:47:11 +0800
committerobscuren <geffobscura@gmail.com>2014-06-25 15:47:11 +0800
commit1e965cb8f5c63d73a5aac1556a2638345ba2824c (patch)
tree92abae274176a0d5388d962794883929a776f2b1 /utils
parentfd1ddbce6892e3f0e09eec68687b6ef34b216888 (diff)
downloaddexon-1e965cb8f5c63d73a5aac1556a2638345ba2824c.tar
dexon-1e965cb8f5c63d73a5aac1556a2638345ba2824c.tar.gz
dexon-1e965cb8f5c63d73a5aac1556a2638345ba2824c.tar.bz2
dexon-1e965cb8f5c63d73a5aac1556a2638345ba2824c.tar.lz
dexon-1e965cb8f5c63d73a5aac1556a2638345ba2824c.tar.xz
dexon-1e965cb8f5c63d73a5aac1556a2638345ba2824c.tar.zst
dexon-1e965cb8f5c63d73a5aac1556a2638345ba2824c.zip
Moved BlockDo to utils
Diffstat (limited to 'utils')
-rw-r--r--utils/cmd.go19
1 files changed, 19 insertions, 0 deletions
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
+
+}