mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 02:40:45 +00:00
core/state, internal/ethapi: GetAccountInfo handle error properly, close XFN-79 (#1663)
This commit is contained in:
parent
39b8184f57
commit
2c40021f71
2 changed files with 7 additions and 3 deletions
|
|
@ -314,14 +314,18 @@ func (s *StateDB) GetAccountInfo(addr common.Address) *AccountInfo {
|
||||||
|
|
||||||
stateObject := s.getStateObject(addr)
|
stateObject := s.getStateObject(addr)
|
||||||
if stateObject == nil {
|
if stateObject == nil {
|
||||||
result.Balance = common.Big0
|
result.Balance = new(big.Int)
|
||||||
return &result
|
return &result
|
||||||
}
|
}
|
||||||
|
|
||||||
if stateObject.code != nil {
|
if stateObject.code != nil {
|
||||||
result.CodeSize = len(stateObject.code)
|
result.CodeSize = len(stateObject.code)
|
||||||
} else {
|
} else {
|
||||||
result.CodeSize, _ = s.db.ContractCodeSize(stateObject.addrHash, common.BytesToHash(stateObject.CodeHash()))
|
size, err := s.db.ContractCodeSize(stateObject.addrHash, common.BytesToHash(stateObject.CodeHash()))
|
||||||
|
if err != nil {
|
||||||
|
s.setError(err)
|
||||||
|
}
|
||||||
|
result.CodeSize = size
|
||||||
}
|
}
|
||||||
result.Nonce = stateObject.Nonce()
|
result.Nonce = stateObject.Nonce()
|
||||||
result.Balance = stateObject.Balance()
|
result.Balance = stateObject.Balance()
|
||||||
|
|
|
||||||
|
|
@ -509,7 +509,7 @@ func (api *BlockChainAPI) GetAccountInfo(ctx context.Context, address common.Add
|
||||||
"nonce": info.Nonce,
|
"nonce": info.Nonce,
|
||||||
"storageHash": info.StorageHash,
|
"storageHash": info.StorageHash,
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, state.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStorageAt returns the storage from the state at the given address, key and
|
// GetStorageAt returns the storage from the state at the given address, key and
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue