aboutsummaryrefslogtreecommitdiffstats
path: root/ethdb
diff options
context:
space:
mode:
Diffstat (limited to 'ethdb')
-rw-r--r--ethdb/database.go8
-rw-r--r--ethdb/interface.go2
-rw-r--r--ethdb/memory_database.go5
3 files changed, 15 insertions, 0 deletions
diff --git a/ethdb/database.go b/ethdb/database.go
index 93755dd7e..9a7c85d9e 100644
--- a/ethdb/database.go
+++ b/ethdb/database.go
@@ -299,6 +299,10 @@ func (b *ldbBatch) ValueSize() int {
return b.size
}
+func (b *ldbBatch) Reset() {
+ b.b.Reset()
+}
+
type table struct {
db Database
prefix string
@@ -358,3 +362,7 @@ func (tb *tableBatch) Write() error {
func (tb *tableBatch) ValueSize() int {
return tb.batch.ValueSize()
}
+
+func (tb *tableBatch) Reset() {
+ tb.batch.Reset()
+}
diff --git a/ethdb/interface.go b/ethdb/interface.go
index 99a5b770d..537312003 100644
--- a/ethdb/interface.go
+++ b/ethdb/interface.go
@@ -41,4 +41,6 @@ type Batch interface {
Putter
ValueSize() int // amount of data in the batch
Write() error
+ // Reset resets the batch for reuse
+ Reset()
}
diff --git a/ethdb/memory_database.go b/ethdb/memory_database.go
index 0dd93a279..8efd7bf84 100644
--- a/ethdb/memory_database.go
+++ b/ethdb/memory_database.go
@@ -123,3 +123,8 @@ func (b *memBatch) Write() error {
func (b *memBatch) ValueSize() int {
return b.size
}
+
+func (b *memBatch) Reset() {
+ b.writes = b.writes[:0]
+ b.size = 0
+}