mirror of https://github.com/ethereum/go-ethereum
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.5 KiB
45 lines
1.5 KiB
6 years ago
|
// Copyright 2018 The go-ethereum Authors
|
||
9 years ago
|
// This file is part of the go-ethereum library.
|
||
9 years ago
|
//
|
||
9 years ago
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||
9 years ago
|
// it under the terms of the GNU Lesser General Public License as published by
|
||
|
// the Free Software Foundation, either version 3 of the License, or
|
||
|
// (at your option) any later version.
|
||
|
//
|
||
9 years ago
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||
9 years ago
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
9 years ago
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
9 years ago
|
// GNU Lesser General Public License for more details.
|
||
|
//
|
||
|
// You should have received a copy of the GNU Lesser General Public License
|
||
9 years ago
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||
9 years ago
|
|
||
9 years ago
|
package ethdb
|
||
11 years ago
|
|
||
6 years ago
|
// IdealBatchSize defines the size of the data batches should ideally add in one
|
||
|
// write.
|
||
7 years ago
|
const IdealBatchSize = 100 * 1024
|
||
|
|
||
|
// Batch is a write-only database that commits changes to its host database
|
||
6 years ago
|
// when Write is called. A batch cannot be used concurrently.
|
||
9 years ago
|
type Batch interface {
|
||
6 years ago
|
Writer
|
||
6 years ago
|
Deleter
|
||
6 years ago
|
|
||
|
// ValueSize retrieves the amount of data queued up for writing.
|
||
|
ValueSize() int
|
||
|
|
||
|
// Write flushes any accumulated data to disk.
|
||
9 years ago
|
Write() error
|
||
6 years ago
|
|
||
7 years ago
|
// Reset resets the batch for reuse
|
||
|
Reset()
|
||
11 years ago
|
}
|
||
6 years ago
|
|
||
|
// Batcher wraps the NewBatch method of a backing data store.
|
||
|
type Batcher interface {
|
||
|
// NewBatch creates a write-only database that buffers changes to its host db
|
||
|
// until a final write is called.
|
||
|
NewBatch() Batch
|
||
|
}
|