From 546af1adc1fae11683891248a8ac983f2fc53fea Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Wed, 30 Apr 2025 08:47:48 +0800 Subject: [PATCH] core, ethdb, trie: rename Sync to SyncKeyValue --- core/headerchain.go | 2 +- core/rawdb/table.go | 8 ++++---- ethdb/database.go | 6 +++--- ethdb/leveldb/leveldb.go | 6 +++--- ethdb/memorydb/memorydb.go | 6 +++--- ethdb/pebble/pebble.go | 6 +++--- ethdb/remotedb/remotedb.go | 2 +- trie/trie_test.go | 2 +- triedb/pathdb/database.go | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/core/headerchain.go b/core/headerchain.go index 477c629dda..abe8086cf8 100644 --- a/core/headerchain.go +++ b/core/headerchain.go @@ -611,7 +611,7 @@ func (hc *HeaderChain) setHead(headBlock uint64, headTime uint64, updateFn Updat } // Explicitly flush the pending writes in the key-value store to disk, ensuring // data durability of the previous deletions. - if err := hc.chainDb.Sync(); err != nil { + if err := hc.chainDb.SyncKeyValue(); err != nil { log.Crit("Failed to sync the key-value store in setHead", "err", err) } // Truncate the excessive chain segments in the ancient store. diff --git a/core/rawdb/table.go b/core/rawdb/table.go index d481fbd3ec..9a342a8217 100644 --- a/core/rawdb/table.go +++ b/core/rawdb/table.go @@ -188,10 +188,10 @@ func (t *table) Compact(start []byte, limit []byte) error { 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() +// SyncKeyValue ensures that all pending writes are flushed to disk, +// guaranteeing data durability up to the point. +func (t *table) SyncKeyValue() error { + return t.db.SyncKeyValue() } // NewBatch creates a write-only database that buffers changes to its host db diff --git a/ethdb/database.go b/ethdb/database.go index f277acb550..fbf142e554 100644 --- a/ethdb/database.go +++ b/ethdb/database.go @@ -59,9 +59,9 @@ type KeyValueStater interface { // 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 + // SyncKeyValue ensures that all pending writes are flushed to disk, + // guaranteeing data durability up to the point. + SyncKeyValue() error } // Compacter wraps the Compact method of a backing data store. diff --git a/ethdb/leveldb/leveldb.go b/ethdb/leveldb/leveldb.go index b583365ac2..223d01aff6 100644 --- a/ethdb/leveldb/leveldb.go +++ b/ethdb/leveldb/leveldb.go @@ -324,9 +324,9 @@ func (db *Database) Path() string { 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 { +// SyncKeyValue flushes all pending writes in the write-ahead-log to disk, +// ensuring data durability up to that point. +func (db *Database) SyncKeyValue() error { // In theory, the WAL (Write-Ahead Log) can be explicitly synchronized using // a write operation with SYNC=true. However, there is no dedicated key reserved // for this purpose, and even a nil key (key=nil) is considered a valid diff --git a/ethdb/memorydb/memorydb.go b/ethdb/memorydb/memorydb.go index c8196f7137..f56727cf4a 100644 --- a/ethdb/memorydb/memorydb.go +++ b/ethdb/memorydb/memorydb.go @@ -199,9 +199,9 @@ func (db *Database) Compact(start []byte, limit []byte) error { return nil } -// Sync ensures that all pending writes are flushed to disk, guaranteeing -// data durability up to the point. -func (db *Database) Sync() error { +// SyncKeyValue ensures that all pending writes are flushed to disk, +// guaranteeing data durability up to the point. +func (db *Database) SyncKeyValue() error { return nil } diff --git a/ethdb/pebble/pebble.go b/ethdb/pebble/pebble.go index 5b2918aa89..9ece995655 100644 --- a/ethdb/pebble/pebble.go +++ b/ethdb/pebble/pebble.go @@ -431,9 +431,9 @@ func (d *Database) Path() string { 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 { +// SyncKeyValue flushes all pending writes in the write-ahead-log to disk, +// ensuring data durability up to that point. +func (d *Database) SyncKeyValue() error { // The entry (value=nil) is not written to the database; it is only // added to the WAL. Writing this special log entry in sync mode // automatically flushes all previous writes, ensuring database diff --git a/ethdb/remotedb/remotedb.go b/ethdb/remotedb/remotedb.go index 13b19facea..a417a25854 100644 --- a/ethdb/remotedb/remotedb.go +++ b/ethdb/remotedb/remotedb.go @@ -138,7 +138,7 @@ func (db *Database) Compact(start []byte, limit []byte) error { return nil } -func (db *Database) Sync() error { +func (db *Database) SyncKeyValue() error { return nil } diff --git a/trie/trie_test.go b/trie/trie_test.go index 0a297b317d..91fde6dbf2 100644 --- a/trie/trie_test.go +++ b/trie/trie_test.go @@ -830,7 +830,7 @@ func (s *spongeDb) NewBatch() ethdb.Batch { return &spongeBat func (s *spongeDb) NewBatchWithSize(size int) ethdb.Batch { return &spongeBatch{s} } func (s *spongeDb) Stat() (string, 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) SyncKeyValue() error { return nil } func (s *spongeDb) Close() error { return nil } func (s *spongeDb) Put(key []byte, value []byte) error { var ( diff --git a/triedb/pathdb/database.go b/triedb/pathdb/database.go index 85103063b5..155e28543d 100644 --- a/triedb/pathdb/database.go +++ b/triedb/pathdb/database.go @@ -460,7 +460,7 @@ func (db *Database) Recover(root common.Hash) error { // recent key-value writes are lost due to an application panic, while // the associated state histories have already been removed, resulting // in the inability to perform a state rollback. - if err := db.diskdb.Sync(); err != nil { + if err := db.diskdb.SyncKeyValue(); err != nil { return err } _, err := truncateFromHead(db.diskdb, db.freezer, dl.stateID())