cmd/utils: use constant for import batch size

This commit is contained in:
Felix Lange 2015-05-28 01:16:57 +02:00
parent a8bc2181c9
commit e1fe75e3b6
1 changed files with 6 additions and 3 deletions

View File

@ -40,6 +40,10 @@ import (
"github.com/peterh/liner"
)
const (
importBatchSize = 2500
)
var interruptCallbacks = []func(os.Signal){}
// Register interrupt handlers callbacks
@ -205,8 +209,7 @@ func ImportChain(chain *core.ChainManager, fn string) error {
stream := rlp.NewStream(fh, 0)
// Run actual the import.
batchSize := 2500
blocks := make(types.Blocks, batchSize)
blocks := make(types.Blocks, importBatchSize)
n := 0
for batch := 0; ; batch++ {
// Load a batch of RLP blocks.
@ -214,7 +217,7 @@ func ImportChain(chain *core.ChainManager, fn string) error {
return fmt.Errorf("interrupted")
}
i := 0
for ; i < batchSize; i++ {
for ; i < importBatchSize; i++ {
var b types.Block
if err := stream.Decode(&b); err == io.EOF {
break