mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-05 15:52:55 +00:00
triedb: get the first state block
Signed-off-by: Delweng <delweng@gmail.com>
This commit is contained in:
parent
cbf0b5bc92
commit
d761acaa06
2 changed files with 32 additions and 0 deletions
|
|
@ -384,3 +384,13 @@ func (db *Database) SnapshotCompleted() bool {
|
||||||
}
|
}
|
||||||
return pdb.SnapshotCompleted()
|
return pdb.SnapshotCompleted()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FirstStateBlock
|
||||||
|
func (db *Database) FirstStateBlock() (uint64, error) {
|
||||||
|
pdb, ok := db.backend.(*pathdb.Database)
|
||||||
|
if !ok {
|
||||||
|
// Ignore in hash scheme
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
return pdb.FirstStateBlock()
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -692,3 +692,25 @@ func (db *Database) SnapshotCompleted() bool {
|
||||||
}
|
}
|
||||||
return db.tree.bottom().genComplete()
|
return db.tree.bottom().genComplete()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FirstStateBlock returns the block number of the oldest state snapshot in the freezer or disk layer.
|
||||||
|
func (db *Database) FirstStateBlock() (uint64, error) {
|
||||||
|
var (
|
||||||
|
m meta
|
||||||
|
err error
|
||||||
|
tailID = db.tree.bottom().stateID()
|
||||||
|
)
|
||||||
|
|
||||||
|
if db.stateFreezer != nil {
|
||||||
|
tailID, err = db.stateFreezer.Tail()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
blob := rawdb.ReadStateHistoryMeta(db.diskdb, tailID)
|
||||||
|
if err := m.decode(blob); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return m.block, nil
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue