From 76025cc4245f0abc0749f4d1e433be865107bf24 Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 20 Apr 2015 16:03:19 +0200 Subject: geth: added a `admin.debug.block` command which reprocess the block --- cmd/geth/admin.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cmd/geth/admin.go b/cmd/geth/admin.go index 1cd0aa2a9..defbb43ec 100644 --- a/cmd/geth/admin.go +++ b/cmd/geth/admin.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" @@ -52,6 +53,7 @@ func (js *jsre) adminBindings() { debug.Set("dumpBlock", js.dumpBlock) debug.Set("getBlockRlp", js.getBlockRlp) debug.Set("setHead", js.setHead) + debug.Set("block", js.debugBlock) } func (js *jsre) getBlock(call otto.FunctionCall) (*types.Block, error) { @@ -72,6 +74,29 @@ func (js *jsre) getBlock(call otto.FunctionCall) (*types.Block, error) { return nil, errors.New("requires block number or block hash as argument") } +func (js *jsre) debugBlock(call otto.FunctionCall) otto.Value { + block, err := js.getBlock(call) + if err != nil { + fmt.Println(err) + return otto.UndefinedValue() + } + + if block == nil { + fmt.Println("block not found") + return otto.UndefinedValue() + } + + old := vm.Debug + vm.Debug = true + _, err = js.ethereum.BlockProcessor().RetryProcess(block) + if err != nil { + glog.Infoln(err) + } + vm.Debug = old + + return otto.UndefinedValue() +} + func (js *jsre) setHead(call otto.FunctionCall) otto.Value { block, err := js.getBlock(call) if err != nil { -- cgit