From 8321a45f46d6317108177e092ca6740ee47f2076 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 7 Sep 2017 13:19:44 +0200 Subject: [PATCH] ethdb: improve docs and add IdealBatchSize --- ethdb/interface.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ethdb/interface.go b/ethdb/interface.go index 7dd07135ca..6a61289bff 100644 --- a/ethdb/interface.go +++ b/ethdb/interface.go @@ -16,10 +16,16 @@ package ethdb +// Code using batches should try to add this much data to the batch. +// The value was determined empirically. +const IdealBatchSize = 100 * 1024 + +// Putter wraps the database write operation supported by both batches and regular databases. type Putter interface { Put(key []byte, value []byte) error } +// Database wraps all database operations. All methods are safe for concurrent use. type Database interface { Putter Get(key []byte) ([]byte, error) @@ -29,6 +35,8 @@ type Database interface { NewBatch() Batch } +// Batch is a write-only database that commits changes to its host database +// when Write is called. Batch cannot be used concurrently. type Batch interface { Putter Write() error