diff --git a/core/bloom_indexer.go b/core/bloom_indexer.go index 856746a1c..68a35d811 100644 --- a/core/bloom_indexer.go +++ b/core/bloom_indexer.go @@ -75,7 +75,7 @@ func (b *BloomIndexer) Process(ctx context.Context, header *types.Header) error // Commit implements core.ChainIndexerBackend, finalizing the bloom section and // writing it out into the database. func (b *BloomIndexer) Commit() error { - batch := b.db.NewBatch() + batch := b.db.NewBatchWithSize((int(b.size) / 8) * types.BloomBitLength) for i := 0; i < types.BloomBitLength; i++ { bits, err := b.gen.Bitset(uint(i)) if err != nil { diff --git a/core/rawdb/table.go b/core/rawdb/table.go index f3d769fc5..efc26de06 100644 --- a/core/rawdb/table.go +++ b/core/rawdb/table.go @@ -189,6 +189,7 @@ func (t *table) DiffStore() ethdb.KeyValueStore { func (t *table) SetDiffStore(diff ethdb.KeyValueStore) { panic("not implement") } + // NewBatchWithSize creates a write-only database batch with pre-allocated buffer. func (t *table) NewBatchWithSize(size int) ethdb.Batch { return &tableBatch{t.db.NewBatchWithSize(size), t.prefix}