Move batch management into the writeReceipts case (#1321)

This commit is contained in:
Horacio Mijail Antón Quiles 2020-10-30 18:41:35 +10:00 committed by GitHub
parent ed7dd7acd3
commit f8477e29ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,11 +95,11 @@ func CheckChangeSets(genesis *core.Genesis, blockNum uint64, chaindata string, h
if err := rawdb.WriteReceipts(batch, block.NumberU64(), receipts); err != nil { if err := rawdb.WriteReceipts(batch, block.NumberU64(), receipts); err != nil {
return err return err
} }
} if batch.BatchSize() >= batch.IdealBatchSize() {
if batch.BatchSize() >= batch.IdealBatchSize() { log.Info("Committing receipts", "up to block", block.NumberU64(), "batch size", common.StorageSize(batch.BatchSize()))
log.Info("Committing receipts", "up to block", block.NumberU64(), "batch size", common.StorageSize(batch.BatchSize())) if err := batch.CommitAndBegin(context.Background()); err != nil {
if err := batch.CommitAndBegin(context.Background()); err != nil { return err
return err }
} }
} }