aboutsummaryrefslogtreecommitdiffstats
path: root/ethereum/main.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-06 15:53:12 +0800
committerobscuren <geffobscura@gmail.com>2014-08-06 15:53:12 +0800
commit852d1ee395feabaa0e72265106374a0df197db9a (patch)
tree2700d53ad6d5d415e2d91c7b71b1e23ba95e4602 /ethereum/main.go
parent3c319f93f2a0e66bc131cfa1e81be840b3242182 (diff)
downloaddexon-852d1ee395feabaa0e72265106374a0df197db9a.tar.gz
dexon-852d1ee395feabaa0e72265106374a0df197db9a.tar.zst
dexon-852d1ee395feabaa0e72265106374a0df197db9a.zip
State dumps
Diffstat (limited to 'ethereum/main.go')
-rw-r--r--ethereum/main.go31
1 files changed, 30 insertions, 1 deletions
diff --git a/ethereum/main.go b/ethereum/main.go
index 9ece8133d..17838997c 100644
--- a/ethereum/main.go
+++ b/ethereum/main.go
@@ -1,8 +1,11 @@
package main
import (
+ "fmt"
+ "os"
"runtime"
+ "github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/go-ethereum/utils"
@@ -24,7 +27,7 @@ func main() {
Init() // parsing command line
// If the difftool option is selected ignore all other log output
- if DiffTool {
+ if DiffTool || Dump {
LogLevel = 0
}
@@ -47,6 +50,32 @@ func main() {
ethereum := utils.NewEthereum(db, clientIdentity, keyManager, UseUPnP, OutboundPort, MaxPeer)
+ if Dump {
+ var block *ethchain.Block
+
+ if len(DumpHash) == 0 && DumpNumber == -1 {
+ block = ethereum.BlockChain().CurrentBlock
+ } else if len(DumpHash) > 0 {
+ block = ethereum.BlockChain().GetBlock(ethutil.Hex2Bytes(DumpHash))
+ } else {
+ block = ethereum.BlockChain().GetBlockByNumber(uint64(DumpNumber))
+ }
+
+ if block == nil {
+ fmt.Fprintln(os.Stderr, "block not found")
+
+ // We want to output valid JSON
+ fmt.Println("{}")
+
+ os.Exit(1)
+ }
+
+ // Leave the Println. This needs clean output for piping
+ fmt.Println(block.State().Dump())
+
+ os.Exit(0)
+ }
+
if ShowGenesis {
utils.ShowGenesis(ethereum)
}