Documentation ¶
Overview ¶
Package light implements on-demand retrieval capable state and chain objects for the Ethereum Light Client.
Index ¶
- Variables
- func DeleteTrustedCht(db ethdb.Database)
- func GetBlock(ctx context.Context, odr OdrBackend, hash common.Hash, number uint64) (*types.Block, error)
- func GetBlockReceipts(ctx context.Context, odr OdrBackend, hash common.Hash, number uint64) (types.Receipts, error)
- func GetBody(ctx context.Context, odr OdrBackend, hash common.Hash, number uint64) (*types.Body, error)
- func GetBodyRLP(ctx context.Context, odr OdrBackend, hash common.Hash, number uint64) (rlp.RawValue, error)
- func GetCanonicalHash(ctx context.Context, odr OdrBackend, number uint64) (common.Hash, error)
- func GetHeaderByNumber(ctx context.Context, odr OdrBackend, number uint64) (*types.Header, error)
- func WriteTrustedCht(db ethdb.Database, cht TrustedCht)
- type BlockRequest
- type ChtNode
- type ChtRequest
- type Code
- type CodeRequest
- type LightChain
- func (self *LightChain) CurrentHeader() *types.Header
- func (self *LightChain) GasLimit() *big.Int
- func (bc *LightChain) Genesis() *types.Block
- func (self *LightChain) GetBlock(ctx context.Context, hash common.Hash, number uint64) (*types.Block, error)
- func (self *LightChain) GetBlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
- func (self *LightChain) GetBlockByNumber(ctx context.Context, number uint64) (*types.Block, error)
- func (self *LightChain) GetBlockHashesFromHash(hash common.Hash, max uint64) []common.Hash
- func (self *LightChain) GetBody(ctx context.Context, hash common.Hash) (*types.Body, error)
- func (self *LightChain) GetBodyRLP(ctx context.Context, hash common.Hash) (rlp.RawValue, error)
- func (self *LightChain) GetHeader(hash common.Hash, number uint64) *types.Header
- func (self *LightChain) GetHeaderByHash(hash common.Hash) *types.Header
- func (self *LightChain) GetHeaderByNumber(number uint64) *types.Header
- func (self *LightChain) GetHeaderByNumberOdr(ctx context.Context, number uint64) (*types.Header, error)
- func (self *LightChain) GetTd(hash common.Hash, number uint64) *big.Int
- func (self *LightChain) GetTdByHash(hash common.Hash) *big.Int
- func (bc *LightChain) HasBlock(hash common.Hash) bool
- func (bc *LightChain) HasHeader(hash common.Hash) bool
- func (self *LightChain) InsertHeaderChain(chain []*types.Header, checkFreq int) (int, error)
- func (self *LightChain) LastBlockHash() common.Hash
- func (self *LightChain) Odr() OdrBackend
- func (bc *LightChain) Reset()
- func (bc *LightChain) ResetWithGenesisBlock(genesis *types.Block)
- func (self *LightChain) Rollback(chain []common.Hash)
- func (bc *LightChain) SetHead(head uint64)
- func (self *LightChain) SetValidator(validator core.HeaderValidator)
- func (self *LightChain) State() *LightState
- func (self *LightChain) Status() (td *big.Int, currentBlock common.Hash, genesisBlock common.Hash)
- func (bc *LightChain) Stop()
- func (self *LightChain) SyncCht(ctx context.Context) bool
- func (self *LightChain) Validator() core.HeaderValidator
- type LightState
- func (self *LightState) AddBalance(ctx context.Context, addr common.Address, amount *big.Int) error
- func (self *LightState) AddRefund(gas *big.Int)
- func (self *LightState) Copy() *LightState
- func (self *LightState) CreateStateObject(ctx context.Context, addr common.Address) (*StateObject, error)
- func (self *LightState) GetBalance(ctx context.Context, addr common.Address) (*big.Int, error)
- func (self *LightState) GetCode(ctx context.Context, addr common.Address) ([]byte, error)
- func (self *LightState) GetNonce(ctx context.Context, addr common.Address) (uint64, error)
- func (self *LightState) GetOrNewStateObject(ctx context.Context, addr common.Address) (*StateObject, error)
- func (self *LightState) GetRefund() *big.Int
- func (self *LightState) GetState(ctx context.Context, a common.Address, b common.Hash) (common.Hash, error)
- func (self *LightState) GetStateObject(ctx context.Context, addr common.Address) (stateObject *StateObject, err error)
- func (self *LightState) HasAccount(ctx context.Context, addr common.Address) (bool, error)
- func (self *LightState) HasSuicided(ctx context.Context, addr common.Address) (bool, error)
- func (self *LightState) Set(state *LightState)
- func (self *LightState) SetCode(ctx context.Context, addr common.Address, code []byte) error
- func (self *LightState) SetNonce(ctx context.Context, addr common.Address, nonce uint64) error
- func (self *LightState) SetState(ctx context.Context, addr common.Address, key common.Hash, value common.Hash) error
- func (self *LightState) SetStateObject(object *StateObject)
- func (self *LightState) Suicide(ctx context.Context, addr common.Address) (bool, error)
- type LightTrie
- type OdrBackend
- type OdrRequest
- type ReceiptsRequest
- type StateObject
- func (c *StateObject) AddBalance(amount *big.Int)
- func (c *StateObject) Address() common.Address
- func (self *StateObject) Balance() *big.Int
- func (self *StateObject) Code() []byte
- func (self *StateObject) Copy() *StateObject
- func (self *StateObject) ForEachStorage(cb func(key, value common.Hash) bool)
- func (self *StateObject) GetState(ctx context.Context, key common.Hash) (common.Hash, error)
- func (self *StateObject) MarkForDeletion()
- func (self *StateObject) Nonce() uint64
- func (c *StateObject) ReturnGas(gas, price *big.Int)
- func (c *StateObject) SetBalance(amount *big.Int)
- func (self *StateObject) SetCode(hash common.Hash, code []byte)
- func (self *StateObject) SetNonce(nonce uint64)
- func (self *StateObject) SetState(k, value common.Hash)
- func (self *StateObject) Storage() Storage
- func (c *StateObject) SubBalance(amount *big.Int)
- func (self *StateObject) Value() *big.Int
- type Storage
- type TrieID
- type TrieRequest
- type TrustedCht
- type TxPool
- func (self *TxPool) Add(ctx context.Context, tx *types.Transaction) error
- func (self *TxPool) AddBatch(ctx context.Context, txs []*types.Transaction)
- func (self *TxPool) Content() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
- func (pool *TxPool) GetNonce(ctx context.Context, addr common.Address) (uint64, error)
- func (tp *TxPool) GetTransaction(hash common.Hash) *types.Transaction
- func (self *TxPool) GetTransactions() (txs types.Transactions)
- func (self *TxPool) RemoveTransactions(txs types.Transactions)
- func (pool *TxPool) RemoveTx(hash common.Hash)
- func (pool *TxPool) Stats() (pending int)
- func (pool *TxPool) Stop()
- type TxRelayBackend
- type VMEnv
- func (self *VMEnv) AddLog(log *vm.Log)
- func (self *VMEnv) BlockNumber() *big.Int
- func (self *VMEnv) Call(me vm.ContractRef, addr common.Address, data []byte, ...) ([]byte, error)
- func (self *VMEnv) CallCode(me vm.ContractRef, addr common.Address, data []byte, ...) ([]byte, error)
- func (self *VMEnv) CanTransfer(from common.Address, balance *big.Int) bool
- func (self *VMEnv) ChainConfig() *params.ChainConfig
- func (self *VMEnv) Coinbase() common.Address
- func (self *VMEnv) Create(me vm.ContractRef, data []byte, gas, price, value *big.Int) ([]byte, common.Address, error)
- func (self *VMEnv) Db() vm.Database
- func (self *VMEnv) DelegateCall(me vm.ContractRef, addr common.Address, data []byte, gas, price *big.Int) ([]byte, error)
- func (self *VMEnv) Depth() int
- func (self *VMEnv) Difficulty() *big.Int
- func (self *VMEnv) Error() error
- func (self *VMEnv) GasLimit() *big.Int
- func (self *VMEnv) GetHash(n uint64) common.Hash
- func (self *VMEnv) Origin() common.Address
- func (self *VMEnv) RevertToSnapshot(idx int)
- func (self *VMEnv) SetDepth(i int)
- func (self *VMEnv) SnapshotDatabase() int
- func (self *VMEnv) Time() *big.Int
- func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int)
- func (self *VMEnv) Vm() vm.Vm
- type VMState
- func (s *VMState) AddBalance(addr common.Address, amount *big.Int)
- func (s *VMState) AddRefund(gas *big.Int)
- func (s *VMState) CreateAccount(addr common.Address) vm.Account
- func (s *VMState) Exist(addr common.Address) bool
- func (s *VMState) GetAccount(addr common.Address) vm.Account
- func (s *VMState) GetBalance(addr common.Address) *big.Int
- func (s *VMState) GetCode(addr common.Address) []byte
- func (s *VMState) GetCodeHash(addr common.Address) common.Hash
- func (s *VMState) GetCodeSize(addr common.Address) int
- func (s *VMState) GetNonce(addr common.Address) uint64
- func (s *VMState) GetRefund() *big.Int
- func (s *VMState) GetState(a common.Address, b common.Hash) common.Hash
- func (s *VMState) HasSuicided(addr common.Address) bool
- func (self *VMState) RevertToSnapshot(idx int)
- func (s *VMState) SetCode(addr common.Address, code []byte)
- func (s *VMState) SetNonce(addr common.Address, nonce uint64)
- func (s *VMState) SetState(addr common.Address, key common.Hash, value common.Hash)
- func (self *VMState) SnapshotDatabase() int
- func (s *VMState) Suicide(addr common.Address) bool
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoTrustedCht = errors.New("No trusted canonical hash trie") ErrNoHeader = errors.New("Header not found") ChtFrequency = uint64(4096) )
var NoOdr = context.Background()
NoOdr is the default context passed to an ODR capable function when the ODR service is not required.
var StartingNonce uint64
StartingNonce determines the default nonce when new accounts are being created.
Functions ¶
func DeleteTrustedCht ¶ added in v1.5.0
func GetBlock ¶
func GetBlock(ctx context.Context, odr OdrBackend, hash common.Hash, number uint64) (*types.Block, error)
GetBlock retrieves an entire block corresponding to the hash, assembling it back from the stored header and body.
func GetBlockReceipts ¶
func GetBlockReceipts(ctx context.Context, odr OdrBackend, hash common.Hash, number uint64) (types.Receipts, error)
GetBlockReceipts retrieves the receipts generated by the transactions included in a block given by its hash.
func GetBody ¶
func GetBody(ctx context.Context, odr OdrBackend, hash common.Hash, number uint64) (*types.Body, error)
GetBody retrieves the block body (transactons, uncles) corresponding to the hash.
func GetBodyRLP ¶
func GetBodyRLP(ctx context.Context, odr OdrBackend, hash common.Hash, number uint64) (rlp.RawValue, error)
GetBodyRLP retrieves the block body (transactions and uncles) in RLP encoding.
func GetCanonicalHash ¶
func GetHeaderByNumber ¶
func WriteTrustedCht ¶ added in v1.5.0
func WriteTrustedCht(db ethdb.Database, cht TrustedCht)
Types ¶
type BlockRequest ¶
type BlockRequest struct { OdrRequest Hash common.Hash Number uint64 Rlp []byte }
BlockRequest is the ODR request type for retrieving block bodies
func (*BlockRequest) StoreResult ¶
func (req *BlockRequest) StoreResult(db ethdb.Database)
StoreResult stores the retrieved data in local database
type ChtRequest ¶
type ChtRequest struct { OdrRequest ChtNum, BlockNum uint64 ChtRoot common.Hash Header *types.Header Td *big.Int Proof []rlp.RawValue }
TrieRequest is the ODR request type for state/storage trie entries
func (*ChtRequest) StoreResult ¶
func (req *ChtRequest) StoreResult(db ethdb.Database)
StoreResult stores the retrieved data in local database
type CodeRequest ¶
type CodeRequest struct { OdrRequest Id *TrieID Hash common.Hash Data []byte }
CodeRequest is the ODR request type for retrieving contract code
func (*CodeRequest) StoreResult ¶
func (req *CodeRequest) StoreResult(db ethdb.Database)
StoreResult stores the retrieved data in local database
type LightChain ¶
type LightChain struct {
// contains filtered or unexported fields
}
LightChain represents a canonical chain that by default only handles block headers, downloading block bodies and receipts on demand through an ODR interface. It only does header validation during chain insertion.
func NewLightChain ¶
func NewLightChain(odr OdrBackend, config *params.ChainConfig, pow pow.PoW, mux *event.TypeMux) (*LightChain, error)
NewLightChain returns a fully initialised light chain using information available in the database. It initialises the default Ethereum header validator.
func (*LightChain) CurrentHeader ¶
func (self *LightChain) CurrentHeader() *types.Header
CurrentHeader retrieves the current head header of the canonical chain. The header is retrieved from the HeaderChain's internal cache.
func (*LightChain) GasLimit ¶
func (self *LightChain) GasLimit() *big.Int
GasLimit returns the gas limit of the current HEAD block.
func (*LightChain) Genesis ¶
func (bc *LightChain) Genesis() *types.Block
Genesis returns the genesis block
func (*LightChain) GetBlock ¶
func (self *LightChain) GetBlock(ctx context.Context, hash common.Hash, number uint64) (*types.Block, error)
GetBlock retrieves a block from the database or ODR service by hash and number, caching it if found.
func (*LightChain) GetBlockByHash ¶
GetBlockByHash retrieves a block from the database or ODR service by hash, caching it if found.
func (*LightChain) GetBlockByNumber ¶
GetBlockByNumber retrieves a block from the database or ODR service by number, caching it (associated with its hash) if found.
func (*LightChain) GetBlockHashesFromHash ¶
GetBlockHashesFromHash retrieves a number of block hashes starting at a given hash, fetching towards the genesis block.
func (*LightChain) GetBody ¶
GetBody retrieves a block body (transactions and uncles) from the database or ODR service by hash, caching it if found.
func (*LightChain) GetBodyRLP ¶
GetBodyRLP retrieves a block body in RLP encoding from the database or ODR service by hash, caching it if found.
func (*LightChain) GetHeader ¶
GetHeader retrieves a block header from the database by hash and number, caching it if found.
func (*LightChain) GetHeaderByHash ¶
func (self *LightChain) GetHeaderByHash(hash common.Hash) *types.Header
GetHeaderByHash retrieves a block header from the database by hash, caching it if found.
func (*LightChain) GetHeaderByNumber ¶
func (self *LightChain) GetHeaderByNumber(number uint64) *types.Header
GetHeaderByNumber retrieves a block header from the database by number, caching it (associated with its hash) if found.
func (*LightChain) GetHeaderByNumberOdr ¶
func (self *LightChain) GetHeaderByNumberOdr(ctx context.Context, number uint64) (*types.Header, error)
GetHeaderByNumberOdr retrieves a block header from the database or network by number, caching it (associated with its hash) if found.
func (*LightChain) GetTd ¶
GetTd retrieves a block's total difficulty in the canonical chain from the database by hash and number, caching it if found.
func (*LightChain) GetTdByHash ¶
func (self *LightChain) GetTdByHash(hash common.Hash) *big.Int
GetTdByHash retrieves a block's total difficulty in the canonical chain from the database by hash, caching it if found.
func (*LightChain) HasBlock ¶
func (bc *LightChain) HasBlock(hash common.Hash) bool
HasBlock checks if a block is fully present in the database or not, caching it if present.
func (*LightChain) HasHeader ¶
func (bc *LightChain) HasHeader(hash common.Hash) bool
HasHeader checks if a block header is present in the database or not, caching it if present.
func (*LightChain) InsertHeaderChain ¶
InsertHeaderChain attempts to insert the given header chain in to the local chain, possibly creating a reorg. If an error is returned, it will return the index number of the failing header as well an error describing what went wrong.
The verify parameter can be used to fine tune whether nonce verification should be done or not. The reason behind the optional check is because some of the header retrieval mechanisms already need to verfy nonces, as well as because nonces can be verified sparsely, not needing to check each.
In the case of a light chain, InsertHeaderChain also creates and posts light chain events when necessary.
func (*LightChain) LastBlockHash ¶ added in v1.5.0
func (self *LightChain) LastBlockHash() common.Hash
LastBlockHash return the hash of the HEAD block.
func (*LightChain) Odr ¶
func (self *LightChain) Odr() OdrBackend
Odr returns the ODR backend of the chain
func (*LightChain) Reset ¶
func (bc *LightChain) Reset()
Reset purges the entire blockchain, restoring it to its genesis state.
func (*LightChain) ResetWithGenesisBlock ¶
func (bc *LightChain) ResetWithGenesisBlock(genesis *types.Block)
ResetWithGenesisBlock purges the entire blockchain, restoring it to the specified genesis state.
func (*LightChain) Rollback ¶
func (self *LightChain) Rollback(chain []common.Hash)
Rollback is designed to remove a chain of links from the database that aren't certain enough to be valid.
func (*LightChain) SetHead ¶
func (bc *LightChain) SetHead(head uint64)
SetHead rewinds the local chain to a new head. Everything above the new head will be deleted and the new one set.
func (*LightChain) SetValidator ¶ added in v1.5.0
func (self *LightChain) SetValidator(validator core.HeaderValidator)
SetValidator sets the validator which is used to validate incoming headers.
func (*LightChain) State ¶
func (self *LightChain) State() *LightState
State returns a new mutable state based on the current HEAD block.
func (*LightChain) Status ¶ added in v1.5.0
Status returns status information about the current chain such as the HEAD Td, the HEAD hash and the hash of the genesis block.
func (*LightChain) Stop ¶
func (bc *LightChain) Stop()
Stop stops the blockchain service. If any imports are currently in progress it will abort them using the procInterrupt.
func (*LightChain) Validator ¶ added in v1.5.0
func (self *LightChain) Validator() core.HeaderValidator
Validator returns the current header validator.
type LightState ¶ added in v1.4.0
type LightState struct {
// contains filtered or unexported fields
}
LightState is a memory representation of a state. This version is ODR capable, caching only the already accessed part of the state, retrieving unknown parts on-demand from the ODR backend. Changes are never stored in the local database, only in the memory objects.
func NewLightState ¶ added in v1.4.0
func NewLightState(id *TrieID, odr OdrBackend) *LightState
NewLightState creates a new LightState with the specified root. Note that the creation of a light state is always successful, even if the root is non-existent. In that case, ODR retrieval will always be unsuccessful and every operation will return with an error or wait for the context to be cancelled.
func (*LightState) AddBalance ¶ added in v1.4.0
AddBalance adds the given amount to the balance of the specified account
func (*LightState) AddRefund ¶ added in v1.5.0
func (self *LightState) AddRefund(gas *big.Int)
AddRefund adds an amount to the refund value collected during a vm execution
func (*LightState) Copy ¶ added in v1.4.0
func (self *LightState) Copy() *LightState
Copy creates a copy of the state
func (*LightState) CreateStateObject ¶ added in v1.4.0
func (self *LightState) CreateStateObject(ctx context.Context, addr common.Address) (*StateObject, error)
CreateStateObject creates creates a new state object and takes ownership. This is different from "NewStateObject"
func (*LightState) GetBalance ¶ added in v1.4.0
GetBalance retrieves the balance from the given address or 0 if the account does not exist
func (*LightState) GetCode ¶ added in v1.4.0
GetCode returns the contract code at the given address or nil if the account does not exist
func (*LightState) GetNonce ¶ added in v1.4.0
GetNonce returns the nonce at the given address or 0 if the account does not exist
func (*LightState) GetOrNewStateObject ¶ added in v1.4.0
func (self *LightState) GetOrNewStateObject(ctx context.Context, addr common.Address) (*StateObject, error)
GetOrNewStateObject returns the state object of the given account or creates a new one if the account does not exist
func (*LightState) GetRefund ¶ added in v1.5.0
func (self *LightState) GetRefund() *big.Int
GetRefund returns the refund value collected during a vm execution
func (*LightState) GetState ¶ added in v1.4.0
func (self *LightState) GetState(ctx context.Context, a common.Address, b common.Hash) (common.Hash, error)
GetState returns the contract storage value at storage address b from the contract address a or common.Hash{} if the account does not exist
func (*LightState) GetStateObject ¶ added in v1.4.0
func (self *LightState) GetStateObject(ctx context.Context, addr common.Address) (stateObject *StateObject, err error)
GetStateObject returns the state object of the given account or nil if the account does not exist
func (*LightState) HasAccount ¶ added in v1.4.0
HasAccount returns true if an account exists at the given address
func (*LightState) HasSuicided ¶ added in v1.5.0
HasSuicided returns true if the given account has been marked for deletion or false if the account does not exist
func (*LightState) Set ¶ added in v1.4.0
func (self *LightState) Set(state *LightState)
Set copies the contents of the given state onto this state, overwriting its contents
func (*LightState) SetCode ¶ added in v1.4.0
SetCode sets the contract code at the specified account
func (*LightState) SetState ¶ added in v1.4.0
func (self *LightState) SetState(ctx context.Context, addr common.Address, key common.Hash, value common.Hash) error
SetState sets the storage value at storage address key of the account addr
func (*LightState) SetStateObject ¶ added in v1.4.0
func (self *LightState) SetStateObject(object *StateObject)
SetStateObject sets the state object of the given account
type LightTrie ¶ added in v1.4.0
type LightTrie struct {
// contains filtered or unexported fields
}
LightTrie is an ODR-capable wrapper around trie.SecureTrie
func NewLightTrie ¶ added in v1.4.0
func NewLightTrie(id *TrieID, odr OdrBackend, useFakeMap bool) *LightTrie
NewLightTrie creates a new LightTrie instance. It doesn't instantly try to access the db or network and retrieve the root node, it only initializes its encapsulated SecureTrie at the first actual operation.
func (*LightTrie) Get ¶ added in v1.4.0
Get returns the value for key stored in the trie. The value bytes must not be modified by the caller.
func (*LightTrie) Update ¶ added in v1.4.0
Update associates key with value in the trie. Subsequent calls to Get will return value. If value has length zero, any existing value is deleted from the trie and calls to Get will return nil.
The value bytes must not be modified by the caller while they are stored in the trie.
type OdrBackend ¶
type OdrBackend interface { Database() ethdb.Database Retrieve(ctx context.Context, req OdrRequest) error }
OdrBackend is an interface to a backend service that handles ODR retrievals
type OdrRequest ¶
OdrRequest is an interface for retrieval requests
type ReceiptsRequest ¶
ReceiptsRequest is the ODR request type for retrieving block bodies
func (*ReceiptsRequest) StoreResult ¶
func (req *ReceiptsRequest) StoreResult(db ethdb.Database)
StoreResult stores the retrieved data in local database
type StateObject ¶ added in v1.4.0
type StateObject struct {
// contains filtered or unexported fields
}
StateObject is a memory representation of an account or contract and its storage. This version is ODR capable, caching only the already accessed part of the storage, retrieving unknown parts on-demand from the ODR backend. Changes are never stored in the local database, only in the memory objects.
func DecodeObject ¶ added in v1.4.0
func DecodeObject(ctx context.Context, stateID *TrieID, address common.Address, odr OdrBackend, data []byte) (*StateObject, error)
DecodeObject decodes an RLP-encoded state object.
func NewStateObject ¶ added in v1.4.0
func NewStateObject(address common.Address, odr OdrBackend) *StateObject
NewStateObject creates a new StateObject of the specified account address
func (*StateObject) AddBalance ¶ added in v1.4.0
func (c *StateObject) AddBalance(amount *big.Int)
AddBalance adds the given amount to the account balance
func (*StateObject) Address ¶ added in v1.4.0
func (c *StateObject) Address() common.Address
Address returns the address of the contract/account
func (*StateObject) Balance ¶ added in v1.4.0
func (self *StateObject) Balance() *big.Int
Balance returns the account balance
func (*StateObject) Code ¶ added in v1.4.0
func (self *StateObject) Code() []byte
Code returns the contract code
func (*StateObject) Copy ¶ added in v1.4.0
func (self *StateObject) Copy() *StateObject
Copy creates a copy of the state object
func (*StateObject) ForEachStorage ¶ added in v1.5.0
func (self *StateObject) ForEachStorage(cb func(key, value common.Hash) bool)
ForEachStorage calls a callback function for every key/value pair found in the local storage cache. Note that unlike core/state.StateObject, light.StateObject only returns cached values and doesn't download the entire storage tree.
func (*StateObject) GetState ¶ added in v1.4.0
GetState returns the storage value at the given address from either the cache or the trie
func (*StateObject) MarkForDeletion ¶ added in v1.4.0
func (self *StateObject) MarkForDeletion()
MarkForDeletion marks an account to be removed
func (*StateObject) Nonce ¶ added in v1.4.0
func (self *StateObject) Nonce() uint64
Nonce returns the account nonce
func (*StateObject) ReturnGas ¶ added in v1.5.0
func (c *StateObject) ReturnGas(gas, price *big.Int)
ReturnGas returns the gas back to the origin. Used by the Virtual machine or Closures
func (*StateObject) SetBalance ¶ added in v1.4.0
func (c *StateObject) SetBalance(amount *big.Int)
SetBalance sets the account balance to the given amount
func (*StateObject) SetCode ¶ added in v1.4.0
func (self *StateObject) SetCode(hash common.Hash, code []byte)
SetCode sets the contract code
func (*StateObject) SetNonce ¶ added in v1.4.0
func (self *StateObject) SetNonce(nonce uint64)
SetNonce sets the account nonce
func (*StateObject) SetState ¶ added in v1.4.0
func (self *StateObject) SetState(k, value common.Hash)
SetState sets the storage value at the given address
func (*StateObject) Storage ¶ added in v1.4.0
func (self *StateObject) Storage() Storage
Storage returns the storage cache object of the account
func (*StateObject) SubBalance ¶ added in v1.4.0
func (c *StateObject) SubBalance(amount *big.Int)
SubBalance subtracts the given amount from the account balance
func (*StateObject) Value ¶ added in v1.5.0
func (self *StateObject) Value() *big.Int
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.
type Storage ¶ added in v1.4.0
Storage is a memory map cache of a contract storage
type TrieID ¶
TrieID identifies a state or account storage trie
func StateTrieID ¶
StateTrieID returns a TrieID for a state trie belonging to a certain block header.
type TrieRequest ¶
type TrieRequest struct { OdrRequest Id *TrieID Key []byte Proof []rlp.RawValue }
TrieRequest is the ODR request type for state/storage trie entries
func (*TrieRequest) StoreResult ¶
func (req *TrieRequest) StoreResult(db ethdb.Database)
StoreResult stores the retrieved data in local database
type TrustedCht ¶ added in v1.5.0
func GetTrustedCht ¶ added in v1.5.0
func GetTrustedCht(db ethdb.Database) TrustedCht
type TxPool ¶
type TxPool struct {
// contains filtered or unexported fields
}
TxPool implements the transaction pool for light clients, which keeps track of the status of locally created transactions, detecting if they are included in a block (mined) or rolled back. There are no queued transactions since we always receive all locally signed transactions in the same order as they are created.
func NewTxPool ¶
func NewTxPool(config *params.ChainConfig, eventMux *event.TypeMux, chain *LightChain, relay TxRelayBackend) *TxPool
NewTxPool creates a new light transaction pool
func (*TxPool) Add ¶
Add adds a transaction to the pool if valid and passes it to the tx relay backend
func (*TxPool) AddBatch ¶
func (self *TxPool) AddBatch(ctx context.Context, txs []*types.Transaction)
AddTransactions adds all valid transactions to the pool and passes them to the tx relay backend
func (*TxPool) Content ¶
func (self *TxPool) Content() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
Content retrieves the data content of the transaction pool, returning all the pending as well as queued transactions, grouped by account and nonce.
func (*TxPool) GetNonce ¶
GetNonce returns the "pending" nonce of a given address. It always queries the nonce belonging to the latest header too in order to detect if another client using the same key sent a transaction.
func (*TxPool) GetTransaction ¶
func (tp *TxPool) GetTransaction(hash common.Hash) *types.Transaction
GetTransaction returns a transaction if it is contained in the pool and nil otherwise.
func (*TxPool) GetTransactions ¶
func (self *TxPool) GetTransactions() (txs types.Transactions)
GetTransactions returns all currently processable transactions. The returned slice may be modified by the caller.
func (*TxPool) RemoveTransactions ¶
func (self *TxPool) RemoveTransactions(txs types.Transactions)
RemoveTransactions removes all given transactions from the pool.
type TxRelayBackend ¶
type TxRelayBackend interface { Send(txs types.Transactions) NewHead(head common.Hash, mined []common.Hash, rollback []common.Hash) Discard(hashes []common.Hash) }
TxRelayBackend provides an interface to the mechanism that forwards transacions to the ETH network. The implementations of the functions should be non-blocking.
Send instructs backend to forward new transactions NewHead notifies backend about a new head after processed by the tx pool,
including mined and rolled back transactions since the last event
Discard notifies backend about transactions that should be discarded either
because they have been replaced by a re-send or because they have been mined long ago and no rollback is expected
type VMEnv ¶ added in v1.5.0
type VMEnv struct { vm.Environment // contains filtered or unexported fields }
VMEnv is the light client version of the vm execution environment. Unlike other structures, VMEnv holds a context that is applied by state retrieval requests through the entire execution. If any state operation returns an error, the execution fails.
func NewEnv ¶ added in v1.5.0
func NewEnv(ctx context.Context, state *LightState, chainConfig *params.ChainConfig, chain *LightChain, msg core.Message, header *types.Header, cfg vm.Config) *VMEnv
NewEnv creates a new execution environment based on an ODR capable light state
func (*VMEnv) BlockNumber ¶ added in v1.5.0
func (*VMEnv) CanTransfer ¶ added in v1.5.0
func (*VMEnv) ChainConfig ¶ added in v1.5.0
func (self *VMEnv) ChainConfig() *params.ChainConfig
func (*VMEnv) DelegateCall ¶ added in v1.5.0
func (*VMEnv) Difficulty ¶ added in v1.5.0
func (*VMEnv) Error ¶ added in v1.5.0
Error returns the error (if any) that happened during execution.
func (*VMEnv) RevertToSnapshot ¶ added in v1.5.0
func (*VMEnv) SnapshotDatabase ¶ added in v1.5.0
type VMState ¶ added in v1.5.0
VMState is a wrapper for the light state that holds the actual context and passes it to any state operation that requires it.
func (*VMState) AddBalance ¶ added in v1.5.0
AddBalance adds the given amount to the balance of the specified account
func (*VMState) AddRefund ¶ added in v1.5.0
AddRefund adds an amount to the refund value collected during a vm execution
func (*VMState) CreateAccount ¶ added in v1.5.0
CreateAccount creates creates a new account object and takes ownership.
func (*VMState) Exist ¶ added in v1.5.0
Exist returns true if an account exists at the given address
func (*VMState) GetAccount ¶ added in v1.5.0
GetAccount returns the account object of the given account or nil if the account does not exist
func (*VMState) GetBalance ¶ added in v1.5.0
GetBalance retrieves the balance from the given address or 0 if the account does not exist
func (*VMState) GetCode ¶ added in v1.5.0
GetCode returns the contract code at the given address or nil if the account does not exist
func (*VMState) GetCodeHash ¶ added in v1.5.0
GetCodeHash returns the contract code hash at the given address
func (*VMState) GetCodeSize ¶ added in v1.5.0
GetCodeSize returns the contract code size at the given address
func (*VMState) GetNonce ¶ added in v1.5.0
GetNonce returns the nonce at the given address or 0 if the account does not exist
func (*VMState) GetRefund ¶ added in v1.5.0
GetRefund returns the refund value collected during a vm execution
func (*VMState) GetState ¶ added in v1.5.0
GetState returns the contract storage value at storage address b from the contract address a or common.Hash{} if the account does not exist
func (*VMState) HasSuicided ¶ added in v1.5.0
HasSuicided returns true if the given account has been marked for deletion or false if the account does not exist
func (*VMState) RevertToSnapshot ¶ added in v1.5.0
func (*VMState) SetState ¶ added in v1.5.0
SetState sets the storage value at storage address key of the account addr