core/state: access trie through Database interface, track errors (#14589)
With this commit, core/state's access to the underlying key/value database is mediated through an interface. Database errors are tracked in StateDB and returned by CommitTo or the new Error method. Motivation for this change: We can remove the light client's duplicated copy of core/state. The light client now supports node iteration, so tracing and storage enumeration can work with the light client (not implemented in this commit).
This commit is contained in:
@@ -106,25 +106,6 @@ func GetCanonicalHash(ctx context.Context, odr OdrBackend, number uint64) (commo
|
||||
return common.Hash{}, err
|
||||
}
|
||||
|
||||
// retrieveContractCode tries to retrieve the contract code of the given account
|
||||
// with the given hash from the network (id points to the storage trie belonging
|
||||
// to the same account)
|
||||
func retrieveContractCode(ctx context.Context, odr OdrBackend, id *TrieID, hash common.Hash) ([]byte, error) {
|
||||
if hash == sha3_nil {
|
||||
return nil, nil
|
||||
}
|
||||
res, _ := odr.Database().Get(hash[:])
|
||||
if res != nil {
|
||||
return res, nil
|
||||
}
|
||||
r := &CodeRequest{Id: id, Hash: hash}
|
||||
if err := odr.Retrieve(ctx, r); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return r.Data, nil
|
||||
}
|
||||
}
|
||||
|
||||
// GetBodyRLP retrieves the block body (transactions and uncles) in RLP encoding.
|
||||
func GetBodyRLP(ctx context.Context, odr OdrBackend, hash common.Hash, number uint64) (rlp.RawValue, error) {
|
||||
if data := core.GetBodyRLP(odr.Database(), hash, number); data != nil {
|
||||
|
Reference in New Issue
Block a user