mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/rawdb, trie/triedb/pathdb: address comments
This commit is contained in:
parent
caad46747e
commit
505ece695a
3 changed files with 10 additions and 10 deletions
|
|
@ -92,7 +92,7 @@ var (
|
|||
transitionStatusKey = []byte("eth2-transition")
|
||||
|
||||
// snapSyncStatusFlagKey flags that status of snap sync.
|
||||
snapSyncStatusFlagKey = []byte("snapSync-status")
|
||||
snapSyncStatusFlagKey = []byte("SnapSyncStatus")
|
||||
|
||||
// Data item prefixes (use single byte to avoid mixing data types, avoid `i`, used for indexes).
|
||||
headerPrefix = []byte("h") // headerPrefix + num (uint64 big endian) + hash -> header
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ type Database struct {
|
|||
// It will be set automatically when the database is journaled during
|
||||
// the shutdown to reject all following unexpected mutations.
|
||||
readOnly bool // Flag if database is opened in read only mode
|
||||
disabled bool // Flag if database is deactivated due to initial state sync
|
||||
waitSync bool // Flag if database is deactivated due to initial state sync
|
||||
bufferSize int // Memory allowance (in bytes) for caching dirty nodes
|
||||
config *Config // Configuration for database
|
||||
diskdb ethdb.Database // Persistent storage for matured trie nodes
|
||||
|
|
@ -251,10 +251,10 @@ func (db *Database) Deactivate() error {
|
|||
return errDatabaseReadOnly
|
||||
}
|
||||
// Prevent duplicated disable operation.
|
||||
if db.disabled {
|
||||
if db.waitSync {
|
||||
return nil
|
||||
}
|
||||
db.disabled = true
|
||||
db.waitSync = true
|
||||
|
||||
// Mark the disk layer as stale to prevent access to persistent state.
|
||||
db.tree.bottom().markStale()
|
||||
|
|
@ -303,7 +303,7 @@ func (db *Database) Activate(root common.Hash) error {
|
|||
db.tree.reset(newDiskLayer(root, 0, db, nil, newNodeBuffer(db.bufferSize, nil, 0)))
|
||||
|
||||
// Re-enable the database as the final step.
|
||||
db.disabled = false
|
||||
db.waitSync = false
|
||||
rawdb.WriteSnapSyncStatusFlag(db.diskdb, rawdb.StateSyncFinished)
|
||||
log.Info("Rebuilt trie database", "root", root)
|
||||
return nil
|
||||
|
|
@ -455,8 +455,8 @@ func (db *Database) modifyAllowed() error {
|
|||
if db.readOnly {
|
||||
return errDatabaseReadOnly
|
||||
}
|
||||
if db.disabled {
|
||||
return errDatabaseDisabled
|
||||
if db.waitSync {
|
||||
return errDatabaseWaitSync
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ var (
|
|||
// to prevent any mutation.
|
||||
errDatabaseReadOnly = errors.New("read only")
|
||||
|
||||
// errDatabaseDisabled is returned if database is disabled due to an ongoing
|
||||
// state sync process.
|
||||
errDatabaseDisabled = errors.New("disabled")
|
||||
// errDatabaseWaitSync is returned if the initial state sync is not completed
|
||||
// yet and database is disabled to prevent accessing state.
|
||||
errDatabaseWaitSync = errors.New("waiting for sync")
|
||||
|
||||
// errSnapshotStale is returned from data accessors if the underlying layer
|
||||
// layer had been invalidated due to the chain progressing forward far enough
|
||||
|
|
|
|||
Loading…
Reference in a new issue