aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/geth/chaincmd.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/geth/chaincmd.go')
-rw-r--r--cmd/geth/chaincmd.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go
index 4f47de5d7..321551ce0 100644
--- a/cmd/geth/chaincmd.go
+++ b/cmd/geth/chaincmd.go
@@ -23,7 +23,6 @@ import (
"strconv"
"time"
- "github.com/codegangsta/cli"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/console"
@@ -32,6 +31,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/logger/glog"
+ "gopkg.in/urfave/cli.v1"
)
var (
@@ -72,7 +72,7 @@ Use "ethereum dump 0" to dump the genesis block.
}
)
-func importChain(ctx *cli.Context) {
+func importChain(ctx *cli.Context) error {
if len(ctx.Args()) != 1 {
utils.Fatalf("This command requires an argument.")
}
@@ -84,9 +84,10 @@ func importChain(ctx *cli.Context) {
utils.Fatalf("Import error: %v", err)
}
fmt.Printf("Import done in %v", time.Since(start))
+ return nil
}
-func exportChain(ctx *cli.Context) {
+func exportChain(ctx *cli.Context) error {
if len(ctx.Args()) < 1 {
utils.Fatalf("This command requires an argument.")
}
@@ -114,9 +115,10 @@ func exportChain(ctx *cli.Context) {
utils.Fatalf("Export error: %v\n", err)
}
fmt.Printf("Export done in %v", time.Since(start))
+ return nil
}
-func removeDB(ctx *cli.Context) {
+func removeDB(ctx *cli.Context) error {
confirm, err := console.Stdin.PromptConfirm("Remove local database?")
if err != nil {
utils.Fatalf("%v", err)
@@ -132,9 +134,10 @@ func removeDB(ctx *cli.Context) {
} else {
fmt.Println("Operation aborted")
}
+ return nil
}
-func upgradeDB(ctx *cli.Context) {
+func upgradeDB(ctx *cli.Context) error {
glog.Infoln("Upgrading blockchain database")
chain, chainDb := utils.MakeChain(ctx)
@@ -163,14 +166,15 @@ func upgradeDB(ctx *cli.Context) {
os.Remove(exportFile)
glog.Infoln("Import finished")
}
+ return nil
}
-func dump(ctx *cli.Context) {
+func dump(ctx *cli.Context) error {
chain, chainDb := utils.MakeChain(ctx)
for _, arg := range ctx.Args() {
var block *types.Block
if hashish(arg) {
- block = chain.GetBlock(common.HexToHash(arg))
+ block = chain.GetBlockByHash(common.HexToHash(arg))
} else {
num, _ := strconv.Atoi(arg)
block = chain.GetBlockByNumber(uint64(num))
@@ -182,12 +186,12 @@ func dump(ctx *cli.Context) {
state, err := state.New(block.Root(), chainDb)
if err != nil {
utils.Fatalf("could not create new state: %v", err)
- return
}
fmt.Printf("%s\n", state.Dump())
}
}
chainDb.Close()
+ return nil
}
// hashish returns true for strings that look like hashes.