ethdb: improve docs and add IdealBatchSize

This commit is contained in:
Felix Lange 2017-09-07 13:19:44 +02:00
parent 2ea88e168c
commit 8321a45f46

View file

@ -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