aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/utils
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/utils')
-rw-r--r--cmd/utils/cmd.go25
-rw-r--r--cmd/utils/flags.go60
2 files changed, 63 insertions, 22 deletions
diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go
index a6140d233..7286f5c5e 100644
--- a/cmd/utils/cmd.go
+++ b/cmd/utils/cmd.go
@@ -155,7 +155,11 @@ func ImportChain(chainmgr *core.ChainManager, fn string) error {
chainmgr.Reset()
stream := rlp.NewStream(fh)
- var i int
+ var i, n int
+
+ batchSize := 2500
+ blocks := make(types.Blocks, batchSize)
+
for ; ; i++ {
var b types.Block
if err := stream.Decode(&b); err == io.EOF {
@@ -163,10 +167,25 @@ func ImportChain(chainmgr *core.ChainManager, fn string) error {
} else if err != nil {
return fmt.Errorf("at block %d: %v", i, err)
}
- if err := chainmgr.InsertChain(types.Blocks{&b}); err != nil {
- return fmt.Errorf("invalid block %d: %v", i, err)
+
+ blocks[n] = &b
+ n++
+
+ if n == batchSize {
+ if err := chainmgr.InsertChain(blocks); err != nil {
+ return fmt.Errorf("invalid block %v", err)
+ }
+ n = 0
+ blocks = make(types.Blocks, batchSize)
+ }
+ }
+
+ if n > 0 {
+ if err := chainmgr.InsertChain(blocks[:n]); err != nil {
+ return fmt.Errorf("invalid block %v", err)
}
}
+
fmt.Printf("imported %d blocks\n", i)
return nil
}
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 3ad06653e..8141fae82 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -7,6 +7,7 @@ import (
"runtime"
"github.com/codegangsta/cli"
+ "github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
@@ -83,6 +84,11 @@ var (
Usage: "Network Id",
Value: eth.NetworkId,
}
+ BlockchainVersionFlag = cli.IntFlag{
+ Name: "blockchainversion",
+ Usage: "Blockchain version",
+ Value: core.BlockChainVersion,
+ }
// miner settings
MinerThreadsFlag = cli.IntFlag{
@@ -237,29 +243,32 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
glog.SetLogDir(ctx.GlobalString(LogFileFlag.Name))
return &eth.Config{
- Name: common.MakeName(clientID, version),
- DataDir: ctx.GlobalString(DataDirFlag.Name),
- ProtocolVersion: ctx.GlobalInt(ProtocolVersionFlag.Name),
- NetworkId: ctx.GlobalInt(NetworkIdFlag.Name),
- LogFile: ctx.GlobalString(LogFileFlag.Name),
- LogLevel: ctx.GlobalInt(LogLevelFlag.Name),
- LogJSON: ctx.GlobalString(LogJSONFlag.Name),
- Etherbase: ctx.GlobalString(EtherbaseFlag.Name),
- MinerThreads: ctx.GlobalInt(MinerThreadsFlag.Name),
- AccountManager: GetAccountManager(ctx),
- VmDebug: ctx.GlobalBool(VMDebugFlag.Name),
- MaxPeers: ctx.GlobalInt(MaxPeersFlag.Name),
- Port: ctx.GlobalString(ListenPortFlag.Name),
- NAT: GetNAT(ctx),
- NodeKey: GetNodeKey(ctx),
- Shh: true,
- Dial: true,
- BootNodes: ctx.GlobalString(BootnodesFlag.Name),
+ Name: common.MakeName(clientID, version),
+ DataDir: ctx.GlobalString(DataDirFlag.Name),
+ ProtocolVersion: ctx.GlobalInt(ProtocolVersionFlag.Name),
+ BlockChainVersion: ctx.GlobalInt(BlockchainVersionFlag.Name),
+ SkipBcVersionCheck: false,
+ NetworkId: ctx.GlobalInt(NetworkIdFlag.Name),
+ LogFile: ctx.GlobalString(LogFileFlag.Name),
+ LogLevel: ctx.GlobalInt(LogLevelFlag.Name),
+ LogJSON: ctx.GlobalString(LogJSONFlag.Name),
+ Etherbase: ctx.GlobalString(EtherbaseFlag.Name),
+ MinerThreads: ctx.GlobalInt(MinerThreadsFlag.Name),
+ AccountManager: GetAccountManager(ctx),
+ VmDebug: ctx.GlobalBool(VMDebugFlag.Name),
+ MaxPeers: ctx.GlobalInt(MaxPeersFlag.Name),
+ Port: ctx.GlobalString(ListenPortFlag.Name),
+ NAT: GetNAT(ctx),
+ NodeKey: GetNodeKey(ctx),
+ Shh: true,
+ Dial: true,
+ BootNodes: ctx.GlobalString(BootnodesFlag.Name),
}
}
func GetChain(ctx *cli.Context) (*core.ChainManager, common.Database, common.Database) {
dataDir := ctx.GlobalString(DataDirFlag.Name)
+
blockDb, err := ethdb.NewLDBDatabase(path.Join(dataDir, "blockchain"))
if err != nil {
Fatalf("Could not open database: %v", err)
@@ -269,7 +278,20 @@ func GetChain(ctx *cli.Context) (*core.ChainManager, common.Database, common.Dat
if err != nil {
Fatalf("Could not open database: %v", err)
}
- return core.NewChainManager(blockDb, stateDb, new(event.TypeMux)), blockDb, stateDb
+
+ extraDb, err := ethdb.NewLDBDatabase(path.Join(dataDir, "extra"))
+ if err != nil {
+ Fatalf("Could not open database: %v", err)
+ }
+
+ eventMux := new(event.TypeMux)
+ chainManager := core.NewChainManager(blockDb, stateDb, eventMux)
+ pow := ethash.New(chainManager)
+ txPool := core.NewTxPool(eventMux, chainManager.State)
+ blockProcessor := core.NewBlockProcessor(stateDb, extraDb, pow, txPool, chainManager, eventMux)
+ chainManager.SetProcessor(blockProcessor)
+
+ return chainManager, blockDb, stateDb
}
func GetAccountManager(ctx *cli.Context) *accounts.Manager {