core/state: add function GetStorageRoot

This commit is contained in:
Daniel Liu 2024-03-06 14:10:08 +08:00
parent 5223454dee
commit bbe08ac6e6
2 changed files with 14 additions and 0 deletions

View file

@ -393,6 +393,10 @@ func (self *stateObject) Nonce() uint64 {
return self.data.Nonce
}
func (self *stateObject) Root() common.Hash {
return self.data.Root
}
// Never called, but must be present to allow stateObject to be used
// as a vm.Account interface that also satisfies the vm.ContractRef
// interface. Interfaces are awesome.

View file

@ -221,6 +221,16 @@ func (self *StateDB) GetNonce(addr common.Address) uint64 {
return 0
}
// GetStorageRoot retrieves the storage root from the given address or empty
// if object not found.
func (self *StateDB) GetStorageRoot(addr common.Address) common.Hash {
stateObject := self.getStateObject(addr)
if stateObject != nil {
return stateObject.Root()
}
return common.Hash{}
}
func (self *StateDB) GetCode(addr common.Address) []byte {
stateObject := self.getStateObject(addr)
if stateObject != nil {