mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
ethdb: improve docs and add IdealBatchSize
This commit is contained in:
parent
2ea88e168c
commit
8321a45f46
1 changed files with 8 additions and 0 deletions
|
|
@ -16,10 +16,16 @@
|
||||||
|
|
||||||
package ethdb
|
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 {
|
type Putter interface {
|
||||||
Put(key []byte, value []byte) error
|
Put(key []byte, value []byte) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Database wraps all database operations. All methods are safe for concurrent use.
|
||||||
type Database interface {
|
type Database interface {
|
||||||
Putter
|
Putter
|
||||||
Get(key []byte) ([]byte, error)
|
Get(key []byte) ([]byte, error)
|
||||||
|
|
@ -29,6 +35,8 @@ type Database interface {
|
||||||
NewBatch() Batch
|
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 {
|
type Batch interface {
|
||||||
Putter
|
Putter
|
||||||
Write() error
|
Write() error
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue