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