Commit e1fe75e3 authored by Felix Lange's avatar Felix Lange

cmd/utils: use constant for import batch size

parent a8bc2181
...@@ -40,6 +40,10 @@ import ( ...@@ -40,6 +40,10 @@ import (
"github.com/peterh/liner" "github.com/peterh/liner"
) )
const (
importBatchSize = 2500
)
var interruptCallbacks = []func(os.Signal){} var interruptCallbacks = []func(os.Signal){}
// Register interrupt handlers callbacks // Register interrupt handlers callbacks
...@@ -205,8 +209,7 @@ func ImportChain(chain *core.ChainManager, fn string) error { ...@@ -205,8 +209,7 @@ func ImportChain(chain *core.ChainManager, fn string) error {
stream := rlp.NewStream(fh, 0) stream := rlp.NewStream(fh, 0)
// Run actual the import. // Run actual the import.
batchSize := 2500 blocks := make(types.Blocks, importBatchSize)
blocks := make(types.Blocks, batchSize)
n := 0 n := 0
for batch := 0; ; batch++ { for batch := 0; ; batch++ {
// Load a batch of RLP blocks. // Load a batch of RLP blocks.
...@@ -214,7 +217,7 @@ func ImportChain(chain *core.ChainManager, fn string) error { ...@@ -214,7 +217,7 @@ func ImportChain(chain *core.ChainManager, fn string) error {
return fmt.Errorf("interrupted") return fmt.Errorf("interrupted")
} }
i := 0 i := 0
for ; i < batchSize; i++ { for ; i < importBatchSize; i++ {
var b types.Block var b types.Block
if err := stream.Decode(&b); err == io.EOF { if err := stream.Decode(&b); err == io.EOF {
break break
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment