core, ethdb, trie: rename Sync to SyncKeyValue

This commit is contained in:
Gary Rong 2025-04-30 08:47:48 +08:00
parent 892113345f
commit 546af1adc1
9 changed files with 20 additions and 20 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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