core/rawdb: add HasCode, HashTrieNode and use them where possible (#24454)
This commit is contained in:
@ -314,8 +314,7 @@ func traverseState(ctx *cli.Context) error {
|
||||
}
|
||||
}
|
||||
if !bytes.Equal(acc.CodeHash, emptyCode) {
|
||||
code := rawdb.ReadCode(chaindb, common.BytesToHash(acc.CodeHash))
|
||||
if len(code) == 0 {
|
||||
if !rawdb.HasCode(chaindb, common.BytesToHash(acc.CodeHash)) {
|
||||
log.Error("Code is missing", "hash", common.BytesToHash(acc.CodeHash))
|
||||
return errors.New("missing code")
|
||||
}
|
||||
@ -386,11 +385,10 @@ func traverseRawState(ctx *cli.Context) error {
|
||||
nodes += 1
|
||||
node := accIter.Hash()
|
||||
|
||||
// Check the present for non-empty hash node(embedded node doesn't
|
||||
// have their own hash).
|
||||
if node != (common.Hash{}) {
|
||||
// Check the present for non-empty hash node(embedded node doesn't
|
||||
// have their own hash).
|
||||
blob := rawdb.ReadTrieNode(chaindb, node)
|
||||
if len(blob) == 0 {
|
||||
if !rawdb.HasTrieNode(chaindb, node) {
|
||||
log.Error("Missing trie node(account)", "hash", node)
|
||||
return errors.New("missing account")
|
||||
}
|
||||
@ -434,8 +432,7 @@ func traverseRawState(ctx *cli.Context) error {
|
||||
}
|
||||
}
|
||||
if !bytes.Equal(acc.CodeHash, emptyCode) {
|
||||
code := rawdb.ReadCode(chaindb, common.BytesToHash(acc.CodeHash))
|
||||
if len(code) == 0 {
|
||||
if !rawdb.HasCode(chaindb, common.BytesToHash(acc.CodeHash)) {
|
||||
log.Error("Code is missing", "account", common.BytesToHash(accIter.LeafKey()))
|
||||
return errors.New("missing code")
|
||||
}
|
||||
|
Reference in New Issue
Block a user