cmd/geth: add db cmd to show metadata (#23900)
* cmd/geth: add db cmd to show metadata * cmd/geth: better output generator status Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com> * cmd: minor Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com> Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
This commit is contained in:
committed by
GitHub
parent
4aab440ee2
commit
51eb5f8ca8
@ -66,6 +66,29 @@ type journalStorage struct {
|
||||
Vals [][]byte
|
||||
}
|
||||
|
||||
func ParseGeneratorStatus(generatorBlob []byte) string {
|
||||
if len(generatorBlob) == 0 {
|
||||
return ""
|
||||
}
|
||||
var generator journalGenerator
|
||||
if err := rlp.DecodeBytes(generatorBlob, &generator); err != nil {
|
||||
log.Warn("failed to decode snapshot generator", "err", err)
|
||||
return ""
|
||||
}
|
||||
// Figure out whether we're after or within an account
|
||||
var m string
|
||||
switch marker := generator.Marker; len(marker) {
|
||||
case common.HashLength:
|
||||
m = fmt.Sprintf("at %#x", marker)
|
||||
case 2 * common.HashLength:
|
||||
m = fmt.Sprintf("in %#x at %#x", marker[:common.HashLength], marker[common.HashLength:])
|
||||
default:
|
||||
m = fmt.Sprintf("%#x", marker)
|
||||
}
|
||||
return fmt.Sprintf(`Done: %v, Accounts: %d, Slots: %d, Storage: %d, Marker: %s`,
|
||||
generator.Done, generator.Accounts, generator.Slots, generator.Storage, m)
|
||||
}
|
||||
|
||||
// loadAndParseJournal tries to parse the snapshot journal in latest format.
|
||||
func loadAndParseJournal(db ethdb.KeyValueStore, base *diskLayer) (snapshot, journalGenerator, error) {
|
||||
// Retrieve the disk layer generator. It must exist, no matter the
|
||||
|
Reference in New Issue
Block a user