From 9b3456d86e3f722063829b0a0de00ec77938a4d2 Mon Sep 17 00:00:00 2001 From: Alexey Akhunov Date: Tue, 10 Jul 2018 10:13:34 +0100 Subject: [PATCH 1/2] Flag to specify a different blockchain file, switch to levelDB backend --- main.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index d36538fc..bef6f3af 100644 --- a/main.go +++ b/main.go @@ -27,6 +27,7 @@ import ( ) var cpuprofile = flag.String("cpuprofile", "", "write cpu profile `file`") +var blockchain = flag.String("blockchain", "blockchain", "file containing blocks to load") var ( // TODO: Document... @@ -50,8 +51,8 @@ func main() { defer pprof.StopCPUProfile() } - stateDB := dbm.NewDB("state", dbm.MemDBBackend, "") - codeDB := dbm.NewDB("code", dbm.MemDBBackend, "") + stateDB := dbm.NewDB("state", dbm.LevelDBBackend, "") + codeDB := dbm.NewDB("code", dbm.LevelDBBackend, "") ethermintDB, err := state.NewDatabase(stateDB, codeDB) if err != nil { @@ -94,7 +95,7 @@ func main() { // command. // // TODO: Allow this to be configurable - input, err := os.Open("blockchain") + input, err := os.Open(*blockchain) if err != nil { panic(err) } @@ -213,12 +214,12 @@ func main() { } n++ - if (n % 1000) == 0 { + if (n % 10000) == 0 { fmt.Printf("processed %d blocks\n", n) } - if n >= 20000 { - break - } + //if n >= 20000 { + // break + //} } fmt.Printf("processed %d blocks\n", n) From f0ada2afca2160c120be86020eb46884ca02695b Mon Sep 17 00:00:00 2001 From: Alexey Akhunov Date: Tue, 10 Jul 2018 10:17:56 +0100 Subject: [PATCH 2/2] Timing --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index bef6f3af..43b5a3fc 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,7 @@ import ( "io" "os" "runtime/pprof" + "time" "github.com/cosmos/ethermint/core" "github.com/cosmos/ethermint/state" @@ -120,6 +121,7 @@ func main() { vmConfig := ethvm.Config{} n := 0 + startTime := time.Now() for { if err = stream.Decode(&block); err == io.EOF { err = nil @@ -215,7 +217,7 @@ func main() { n++ if (n % 10000) == 0 { - fmt.Printf("processed %d blocks\n", n) + fmt.Printf("processed %d blocks, time so far: %v\n", n, time.Since(startTime)) } //if n >= 20000 { // break