core/rawdb, triedb/pathdb: fix freezer read-only option (#29823)
This commit is contained in:
parent
61932e4710
commit
b88051ec83
@ -33,6 +33,7 @@ type freezerOpenFunc = func() (*Freezer, error)
|
|||||||
// resettableFreezer is a wrapper of the freezer which makes the
|
// resettableFreezer is a wrapper of the freezer which makes the
|
||||||
// freezer resettable.
|
// freezer resettable.
|
||||||
type resettableFreezer struct {
|
type resettableFreezer struct {
|
||||||
|
readOnly bool
|
||||||
freezer *Freezer
|
freezer *Freezer
|
||||||
opener freezerOpenFunc
|
opener freezerOpenFunc
|
||||||
datadir string
|
datadir string
|
||||||
@ -60,6 +61,7 @@ func newResettableFreezer(datadir string, namespace string, readonly bool, maxTa
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &resettableFreezer{
|
return &resettableFreezer{
|
||||||
|
readOnly: readonly,
|
||||||
freezer: freezer,
|
freezer: freezer,
|
||||||
opener: opener,
|
opener: opener,
|
||||||
datadir: datadir,
|
datadir: datadir,
|
||||||
@ -74,6 +76,9 @@ func (f *resettableFreezer) Reset() error {
|
|||||||
f.lock.Lock()
|
f.lock.Lock()
|
||||||
defer f.lock.Unlock()
|
defer f.lock.Unlock()
|
||||||
|
|
||||||
|
if f.readOnly {
|
||||||
|
return errReadOnly
|
||||||
|
}
|
||||||
if err := f.freezer.Close(); err != nil {
|
if err := f.freezer.Close(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ func (db *Database) repairHistory() error {
|
|||||||
// all of them. Fix the tests first.
|
// all of them. Fix the tests first.
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
freezer, err := rawdb.NewStateFreezer(ancient, false)
|
freezer, err := rawdb.NewStateFreezer(ancient, db.readOnly)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Crit("Failed to open state history freezer", "err", err)
|
log.Crit("Failed to open state history freezer", "err", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user