Moved import to utils

This commit is contained in:
obscuren
2014-12-23 15:37:03 +01:00
parent 7d2353f24d
commit 1054c155db
2 changed files with 26 additions and 18 deletions

View File

@ -26,7 +26,6 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/rlp"
)
const (
@ -118,26 +117,11 @@ func main() {
}
if len(ImportChain) > 0 {
clilogger.Infof("importing chain '%s'\n", ImportChain)
fh, err := os.OpenFile(ImportChain, os.O_RDONLY, os.ModePerm)
err := utils.ImportChain(ethereum, ImportChain)
if err != nil {
clilogger.Infoln(err)
return
}
defer fh.Close()
var chain types.Blocks
if err := rlp.Decode(fh, &chain); err != nil {
clilogger.Infoln(err)
return
}
ethereum.ChainManager().Reset()
if err := ethereum.ChainManager().InsertChain(chain); err != nil {
clilogger.Infoln(err)
return
}
clilogger.Infof("imported %d blocks\n", len(chain))
return
}
// better reworked as cases