mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
core/rawdb, ethdb, trie: implement db.Sync
This commit is contained in:
parent
7fe474b24c
commit
1665dfecba
7 changed files with 39 additions and 0 deletions
|
|
@ -188,6 +188,12 @@ func (t *table) Compact(start []byte, limit []byte) error {
|
||||||
return t.db.Compact(start, limit)
|
return t.db.Compact(start, limit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sync ensures that all pending writes are flushed to disk, guaranteeing
|
||||||
|
// data durability up to the point.
|
||||||
|
func (t *table) Sync() error {
|
||||||
|
return t.db.Sync()
|
||||||
|
}
|
||||||
|
|
||||||
// NewBatch creates a write-only database that buffers changes to its host db
|
// NewBatch creates a write-only database that buffers changes to its host db
|
||||||
// until a final write is called, each operation prefixing all keys with the
|
// until a final write is called, each operation prefixing all keys with the
|
||||||
// pre-configured string.
|
// pre-configured string.
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,13 @@ type KeyValueStater interface {
|
||||||
Stat() (string, error)
|
Stat() (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KeyValueSyncer wraps the Sync method of a backing data store.
|
||||||
|
type KeyValueSyncer interface {
|
||||||
|
// Sync ensures that all pending writes are flushed to disk, guaranteeing
|
||||||
|
// data durability up to the point.
|
||||||
|
Sync() error
|
||||||
|
}
|
||||||
|
|
||||||
// Compacter wraps the Compact method of a backing data store.
|
// Compacter wraps the Compact method of a backing data store.
|
||||||
type Compacter interface {
|
type Compacter interface {
|
||||||
// Compact flattens the underlying data store for the given key range. In essence,
|
// Compact flattens the underlying data store for the given key range. In essence,
|
||||||
|
|
@ -75,6 +82,7 @@ type KeyValueStore interface {
|
||||||
KeyValueReader
|
KeyValueReader
|
||||||
KeyValueWriter
|
KeyValueWriter
|
||||||
KeyValueStater
|
KeyValueStater
|
||||||
|
KeyValueSyncer
|
||||||
KeyValueRangeDeleter
|
KeyValueRangeDeleter
|
||||||
Batcher
|
Batcher
|
||||||
Iteratee
|
Iteratee
|
||||||
|
|
|
||||||
|
|
@ -324,6 +324,12 @@ func (db *Database) Path() string {
|
||||||
return db.fn
|
return db.fn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sync flushes all pending writes in the write-ahead-log to disk, ensuring
|
||||||
|
// data durability up to that point.
|
||||||
|
func (db *Database) Sync() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// meter periodically retrieves internal leveldb counters and reports them to
|
// meter periodically retrieves internal leveldb counters and reports them to
|
||||||
// the metrics subsystem.
|
// the metrics subsystem.
|
||||||
func (db *Database) meter(refresh time.Duration, namespace string) {
|
func (db *Database) meter(refresh time.Duration, namespace string) {
|
||||||
|
|
|
||||||
|
|
@ -199,6 +199,12 @@ func (db *Database) Compact(start []byte, limit []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sync ensures that all pending writes are flushed to disk, guaranteeing
|
||||||
|
// data durability up to the point.
|
||||||
|
func (db *Database) Sync() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Len returns the number of entries currently present in the memory database.
|
// Len returns the number of entries currently present in the memory database.
|
||||||
//
|
//
|
||||||
// Note, this method is only used for testing (i.e. not public in general) and
|
// Note, this method is only used for testing (i.e. not public in general) and
|
||||||
|
|
|
||||||
|
|
@ -414,6 +414,14 @@ func (d *Database) Path() string {
|
||||||
return d.fn
|
return d.fn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sync flushes all pending writes in the write-ahead-log to disk, ensuring
|
||||||
|
// data durability up to that point.
|
||||||
|
func (d *Database) Sync() error {
|
||||||
|
b := d.db.NewBatch()
|
||||||
|
b.LogData(nil, nil)
|
||||||
|
return d.db.Apply(b, pebble.Sync)
|
||||||
|
}
|
||||||
|
|
||||||
// meter periodically retrieves internal pebble counters and reports them to
|
// meter periodically retrieves internal pebble counters and reports them to
|
||||||
// the metrics subsystem.
|
// the metrics subsystem.
|
||||||
func (d *Database) meter(refresh time.Duration, namespace string) {
|
func (d *Database) meter(refresh time.Duration, namespace string) {
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,10 @@ func (db *Database) Compact(start []byte, limit []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *Database) Sync() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (db *Database) Close() error {
|
func (db *Database) Close() error {
|
||||||
db.remote.Close()
|
db.remote.Close()
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -830,6 +830,7 @@ func (s *spongeDb) NewBatch() ethdb.Batch { return &spongeBat
|
||||||
func (s *spongeDb) NewBatchWithSize(size int) ethdb.Batch { return &spongeBatch{s} }
|
func (s *spongeDb) NewBatchWithSize(size int) ethdb.Batch { return &spongeBatch{s} }
|
||||||
func (s *spongeDb) Stat() (string, error) { panic("implement me") }
|
func (s *spongeDb) Stat() (string, error) { panic("implement me") }
|
||||||
func (s *spongeDb) Compact(start []byte, limit []byte) error { panic("implement me") }
|
func (s *spongeDb) Compact(start []byte, limit []byte) error { panic("implement me") }
|
||||||
|
func (s *spongeDb) Sync() error { return nil }
|
||||||
func (s *spongeDb) Close() error { return nil }
|
func (s *spongeDb) Close() error { return nil }
|
||||||
func (s *spongeDb) Put(key []byte, value []byte) error {
|
func (s *spongeDb) Put(key []byte, value []byte) error {
|
||||||
var (
|
var (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue