core/state: rm panic and use log

This commit is contained in:
YESUNFEI 2024-12-11 15:58:15 +08:00 committed by GitHub
parent 330190e476
commit caa7b86111
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -135,7 +135,8 @@ func (s *StateDB) DumpToCollector(c DumpCollector, conf *DumpConfig) (nextKey []
for it.Next() { for it.Next() {
var data types.StateAccount var data types.StateAccount
if err := rlp.DecodeBytes(it.Value, &data); err != nil { if err := rlp.DecodeBytes(it.Value, &data); err != nil {
panic(err) log.Error("Failed to decode", "err", err)
continue
} }
var ( var (
account = DumpAccount{ account = DumpAccount{
@ -149,15 +150,13 @@ func (s *StateDB) DumpToCollector(c DumpCollector, conf *DumpConfig) (nextKey []
addr common.Address addr common.Address
addrBytes = s.trie.GetKey(it.Key) addrBytes = s.trie.GetKey(it.Key)
) )
if addrBytes == nil { if addrBytes != nil {
missingPreimages++
if conf.OnlyWithAddresses {
continue
}
} else {
addr = common.BytesToAddress(addrBytes) addr = common.BytesToAddress(addrBytes)
address = &addr account.Address = &addr
account.Address = address } else if conf.OnlyWithAddresses {
continue
} else {
missingPreimages++
} }
obj := newObject(s, addr, &data) obj := newObject(s, addr, &data)
if !conf.SkipCode { if !conf.SkipCode {