Flag to specify a different blockchain file, switch to levelDB backend

This commit is contained in:
Alexey Akhunov 2018-07-10 10:13:34 +01:00
parent 32e98c71f1
commit 9b3456d86e

15
main.go
View File

@ -27,6 +27,7 @@ import (
) )
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile `file`") var cpuprofile = flag.String("cpuprofile", "", "write cpu profile `file`")
var blockchain = flag.String("blockchain", "blockchain", "file containing blocks to load")
var ( var (
// TODO: Document... // TODO: Document...
@ -50,8 +51,8 @@ func main() {
defer pprof.StopCPUProfile() defer pprof.StopCPUProfile()
} }
stateDB := dbm.NewDB("state", dbm.MemDBBackend, "") stateDB := dbm.NewDB("state", dbm.LevelDBBackend, "")
codeDB := dbm.NewDB("code", dbm.MemDBBackend, "") codeDB := dbm.NewDB("code", dbm.LevelDBBackend, "")
ethermintDB, err := state.NewDatabase(stateDB, codeDB) ethermintDB, err := state.NewDatabase(stateDB, codeDB)
if err != nil { if err != nil {
@ -94,7 +95,7 @@ func main() {
// command. // command.
// //
// TODO: Allow this to be configurable // TODO: Allow this to be configurable
input, err := os.Open("blockchain") input, err := os.Open(*blockchain)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -213,12 +214,12 @@ func main() {
} }
n++ n++
if (n % 1000) == 0 { if (n % 10000) == 0 {
fmt.Printf("processed %d blocks\n", n) fmt.Printf("processed %d blocks\n", n)
} }
if n >= 20000 { //if n >= 20000 {
break // break
} //}
} }
fmt.Printf("processed %d blocks\n", n) fmt.Printf("processed %d blocks\n", n)