forked from cerc-io/plugeth
core, ethdb: reuse database batches (#15989)
* leveldb: Update leveldb to 211f780 (poolfix) * core, ethdb: reuse database batches
This commit is contained in:
parent
6198c53e28
commit
017b9f7eac
@ -749,7 +749,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
bytes += batch.ValueSize()
|
bytes += batch.ValueSize()
|
||||||
batch = bc.chainDb.NewBatch()
|
batch.Reset()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if batch.ValueSize() > 0 {
|
if batch.ValueSize() > 0 {
|
||||||
|
@ -299,6 +299,10 @@ func (b *ldbBatch) ValueSize() int {
|
|||||||
return b.size
|
return b.size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *ldbBatch) Reset() {
|
||||||
|
b.b.Reset()
|
||||||
|
}
|
||||||
|
|
||||||
type table struct {
|
type table struct {
|
||||||
db Database
|
db Database
|
||||||
prefix string
|
prefix string
|
||||||
@ -358,3 +362,7 @@ func (tb *tableBatch) Write() error {
|
|||||||
func (tb *tableBatch) ValueSize() int {
|
func (tb *tableBatch) ValueSize() int {
|
||||||
return tb.batch.ValueSize()
|
return tb.batch.ValueSize()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tb *tableBatch) Reset() {
|
||||||
|
tb.batch.Reset()
|
||||||
|
}
|
||||||
|
@ -41,4 +41,6 @@ type Batch interface {
|
|||||||
Putter
|
Putter
|
||||||
ValueSize() int // amount of data in the batch
|
ValueSize() int // amount of data in the batch
|
||||||
Write() error
|
Write() error
|
||||||
|
// Reset resets the batch for reuse
|
||||||
|
Reset()
|
||||||
}
|
}
|
||||||
|
@ -123,3 +123,8 @@ func (b *memBatch) Write() error {
|
|||||||
func (b *memBatch) ValueSize() int {
|
func (b *memBatch) ValueSize() int {
|
||||||
return b.size
|
return b.size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *memBatch) Reset() {
|
||||||
|
b.writes = b.writes[:0]
|
||||||
|
b.size = 0
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user