Merge pull request #19 from ledgerwatch/develop

Flag for specifying blockchain file, timing, switch to LevelDB backend
This commit is contained in:
ledgerwatch 2018-07-10 10:19:08 +01:00 committed by GitHub
commit 5b9809d130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

19
main.go
View File

@ -12,6 +12,7 @@ import (
"io" "io"
"os" "os"
"runtime/pprof" "runtime/pprof"
"time"
"github.com/cosmos/ethermint/core" "github.com/cosmos/ethermint/core"
"github.com/cosmos/ethermint/state" "github.com/cosmos/ethermint/state"
@ -27,6 +28,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 +52,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 +96,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)
} }
@ -119,6 +121,7 @@ func main() {
vmConfig := ethvm.Config{} vmConfig := ethvm.Config{}
n := 0 n := 0
startTime := time.Now()
for { for {
if err = stream.Decode(&block); err == io.EOF { if err = stream.Decode(&block); err == io.EOF {
err = nil err = nil
@ -213,12 +216,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, time so far: %v\n", n, time.Since(startTime))
}
if n >= 20000 {
break
} }
//if n >= 20000 {
// break
//}
} }
fmt.Printf("processed %d blocks\n", n) fmt.Printf("processed %d blocks\n", n)