aboutsummaryrefslogtreecommitdiffstats
path: root/internal/ethapi/backend.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@users.noreply.github.com>2017-06-27 21:57:06 +0800
committerGitHub <noreply@github.com>2017-06-27 21:57:06 +0800
commit9e5f03b6c487175cc5aa1224e5e12fd573f483a7 (patch)
tree475e573ff6c7e77cd069a2f6238afdb27d4bce43 /internal/ethapi/backend.go
parentbb366271fe33cf87b462dc5a25ac6c448ac6d2e1 (diff)
downloaddexon-9e5f03b6c487175cc5aa1224e5e12fd573f483a7.tar.gz
dexon-9e5f03b6c487175cc5aa1224e5e12fd573f483a7.tar.zst
dexon-9e5f03b6c487175cc5aa1224e5e12fd573f483a7.zip
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).
Diffstat (limited to 'internal/ethapi/backend.go')
-rw-r--r--internal/ethapi/backend.go13
1 files changed, 4 insertions, 9 deletions
diff --git a/internal/ethapi/backend.go b/internal/ethapi/backend.go
index 68b5069d0..d122b7915 100644
--- a/internal/ethapi/backend.go
+++ b/internal/ethapi/backend.go
@@ -24,6 +24,7 @@ import (
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
+ "github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/eth/downloader"
@@ -47,11 +48,12 @@ type Backend interface {
SetHead(number uint64)
HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error)
BlockByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Block, error)
- StateAndHeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (State, *types.Header, error)
+ StateAndHeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*state.StateDB, *types.Header, error)
GetBlock(ctx context.Context, blockHash common.Hash) (*types.Block, error)
GetReceipts(ctx context.Context, blockHash common.Hash) (types.Receipts, error)
GetTd(blockHash common.Hash) *big.Int
- GetEVM(ctx context.Context, msg core.Message, state State, header *types.Header, vmCfg vm.Config) (*vm.EVM, func() error, error)
+ GetEVM(ctx context.Context, msg core.Message, state *state.StateDB, header *types.Header, vmCfg vm.Config) (*vm.EVM, func() error, error)
+
// TxPool API
SendTx(ctx context.Context, signedTx *types.Transaction) error
RemoveTx(txHash common.Hash)
@@ -65,13 +67,6 @@ type Backend interface {
CurrentBlock() *types.Block
}
-type State interface {
- GetBalance(ctx context.Context, addr common.Address) (*big.Int, error)
- GetCode(ctx context.Context, addr common.Address) ([]byte, error)
- GetState(ctx context.Context, a common.Address, b common.Hash) (common.Hash, error)
- GetNonce(ctx context.Context, addr common.Address) (uint64, error)
-}
-
func GetAPIs(apiBackend Backend) []rpc.API {
nonceLock := new(AddrLocker)
return []rpc.API{