mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-23 12:07:17 +00:00
cmd/utils: use constant for import batch size
This commit is contained in:
parent
a8bc2181c9
commit
e1fe75e3b6
@ -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 {
|
|||||||
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 {
|
|||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user