Documentation

Overview

    Package light implements on-demand retrieval capable state and chain objects for the Ethereum Light Client.

    Index

    Constants

    This section is empty.

    Variables

    View Source
    var (
    	// DefaultServerIndexerConfig wraps a set of configs as a default indexer config for server side.
    	DefaultServerIndexerConfig = &IndexerConfig{
    		ChtSize:           params.CHTFrequency,
    		ChtConfirms:       params.HelperTrieProcessConfirmations,
    		BloomSize:         params.BloomBitsBlocks,
    		BloomConfirms:     params.BloomConfirms,
    		BloomTrieSize:     params.BloomTrieFrequency,
    		BloomTrieConfirms: params.HelperTrieProcessConfirmations,
    	}
    	// DefaultClientIndexerConfig wraps a set of configs as a default indexer config for client side.
    	DefaultClientIndexerConfig = &IndexerConfig{
    		ChtSize:           params.CHTFrequency,
    		ChtConfirms:       params.HelperTrieConfirmations,
    		BloomSize:         params.BloomBitsBlocksClient,
    		BloomConfirms:     params.HelperTrieConfirmations,
    		BloomTrieSize:     params.BloomTrieFrequency,
    		BloomTrieConfirms: params.HelperTrieConfirmations,
    	}
    	// TestServerIndexerConfig wraps a set of configs as a test indexer config for server side.
    	TestServerIndexerConfig = &IndexerConfig{
    		ChtSize:           128,
    		ChtConfirms:       1,
    		BloomSize:         16,
    		BloomConfirms:     1,
    		BloomTrieSize:     128,
    		BloomTrieConfirms: 1,
    	}
    	// TestClientIndexerConfig wraps a set of configs as a test indexer config for client side.
    	TestClientIndexerConfig = &IndexerConfig{
    		ChtSize:           128,
    		ChtConfirms:       8,
    		BloomSize:         128,
    		BloomConfirms:     8,
    		BloomTrieSize:     128,
    		BloomTrieConfirms: 8,
    	}
    )
    View Source
    var (
    	BloomTrieTablePrefix = "blt-"
    )
    View Source
    var (
    	ChtTablePrefix = "cht-"
    )
    View Source
    var ErrNoPeers = errors.New("no suitable peers available")

      ErrNoPeers is returned if no peers capable of serving a queued request are available

        NoOdr is the default context passed to an ODR capable function when the ODR service is not required.

        Functions

        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 GetBlockLogs

          func GetBlockLogs(ctx context.Context, odr OdrBackend, hash common.Hash, number uint64) ([][]*types.Log, error)

            GetBlockLogs retrieves the logs generated by the transactions included in a block given by its hash.

            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 GetBloomBits

              func GetBloomBits(ctx context.Context, odr OdrBackend, bitIdx uint, sectionIdxList []uint64) ([][]byte, error)

                GetBloomBits retrieves a batch of compressed bloomBits vectors belonging to the given bit index and section indexes

                func GetBloomTrieRoot

                func GetBloomTrieRoot(db ethdb.Database, sectionIdx uint64, sectionHead common.Hash) common.Hash

                  GetBloomTrieRoot reads the BloomTrie root assoctiated to the given section from the database

                  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 GetCanonicalHash(ctx context.Context, odr OdrBackend, number uint64) (common.Hash, error)

                      func GetChtRoot

                      func GetChtRoot(db ethdb.Database, sectionIdx uint64, sectionHead common.Hash) common.Hash

                        GetChtRoot reads the CHT root associated to the given section from the database

                        func GetHeaderByNumber

                        func GetHeaderByNumber(ctx context.Context, odr OdrBackend, number uint64) (*types.Header, error)

                        func GetTransaction

                        func GetTransaction(ctx context.Context, odr OdrBackend, txHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error)

                          GetTransaction retrieves a canonical transaction by hash and also returns its position in the chain

                          func GetUntrustedBlockLogs

                          func GetUntrustedBlockLogs(ctx context.Context, odr OdrBackend, header *types.Header) ([][]*types.Log, error)

                            GetUntrustedBlockLogs retrieves the logs generated by the transactions included in a block. The retrieved logs are regarded as untrusted and will not be stored in the database. This function should only be used in light client checkpoint syncing.

                            func GetUntrustedHeaderByNumber

                            func GetUntrustedHeaderByNumber(ctx context.Context, odr OdrBackend, number uint64, peerId string) (*types.Header, error)

                              GetUntrustedHeaderByNumber fetches specified block header without correctness checking. Note this function should only be used in light client checkpoint syncing.

                              func NewBloomTrieIndexer

                              func NewBloomTrieIndexer(db ethdb.Database, odr OdrBackend, parentSize, size uint64) *core.ChainIndexer

                                NewBloomTrieIndexer creates a BloomTrie chain indexer

                                func NewChtIndexer

                                func NewChtIndexer(db ethdb.Database, odr OdrBackend, size, confirms uint64) *core.ChainIndexer

                                  NewChtIndexer creates a Cht chain indexer

                                  func NewState

                                  func NewState(ctx context.Context, head *types.Header, odr OdrBackend) *state.StateDB

                                  func NewStateDatabase

                                  func NewStateDatabase(ctx context.Context, head *types.Header, odr OdrBackend) state.Database

                                  func StoreBloomTrieRoot

                                  func StoreBloomTrieRoot(db ethdb.Database, sectionIdx uint64, sectionHead, root common.Hash)

                                    StoreBloomTrieRoot writes the BloomTrie root assoctiated to the given section into the database

                                    func StoreChtRoot

                                    func StoreChtRoot(db ethdb.Database, sectionIdx uint64, sectionHead, root common.Hash)

                                      StoreChtRoot writes the CHT root associated to the given section into the database

                                      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 BloomRequest

                                          type BloomRequest struct {
                                          	OdrRequest
                                          	Config           *IndexerConfig
                                          	BloomTrieNum     uint64
                                          	BitIdx           uint
                                          	SectionIndexList []uint64
                                          	BloomTrieRoot    common.Hash
                                          	BloomBits        [][]byte
                                          	Proofs           *NodeSet
                                          }

                                            BloomRequest is the ODR request type for retrieving bloom filters from a CHT structure

                                            func (*BloomRequest) StoreResult

                                            func (req *BloomRequest) StoreResult(db ethdb.Database)

                                              StoreResult stores the retrieved data in local database

                                              type BloomTrieIndexerBackend

                                              type BloomTrieIndexerBackend struct {
                                              	// contains filtered or unexported fields
                                              }

                                                BloomTrieIndexerBackend implements core.ChainIndexerBackend

                                                func (*BloomTrieIndexerBackend) Commit

                                                func (b *BloomTrieIndexerBackend) Commit() error

                                                  Commit implements core.ChainIndexerBackend

                                                  func (*BloomTrieIndexerBackend) Process

                                                  func (b *BloomTrieIndexerBackend) Process(ctx context.Context, header *types.Header) error

                                                    Process implements core.ChainIndexerBackend

                                                    func (*BloomTrieIndexerBackend) Reset

                                                    func (b *BloomTrieIndexerBackend) Reset(ctx context.Context, section uint64, lastSectionHead common.Hash) error

                                                      Reset implements core.ChainIndexerBackend

                                                      type ChtIndexerBackend

                                                      type ChtIndexerBackend struct {
                                                      	// contains filtered or unexported fields
                                                      }

                                                        ChtIndexerBackend implements core.ChainIndexerBackend.

                                                        func (*ChtIndexerBackend) Commit

                                                        func (c *ChtIndexerBackend) Commit() error

                                                          Commit implements core.ChainIndexerBackend

                                                          func (*ChtIndexerBackend) Process

                                                          func (c *ChtIndexerBackend) Process(ctx context.Context, header *types.Header) error

                                                            Process implements core.ChainIndexerBackend

                                                            func (*ChtIndexerBackend) Reset

                                                            func (c *ChtIndexerBackend) Reset(ctx context.Context, section uint64, lastSectionHead common.Hash) error

                                                              Reset implements core.ChainIndexerBackend

                                                              type ChtNode

                                                              type ChtNode struct {
                                                              	Hash common.Hash
                                                              	Td   *big.Int
                                                              }

                                                                ChtNode structures are stored in the Canonical Hash Trie in an RLP encoded format

                                                                type ChtRequest

                                                                type ChtRequest struct {
                                                                	OdrRequest
                                                                	Untrusted        bool   // Indicator whether the result retrieved is trusted or not
                                                                	PeerId           string // The specified peer id from which to retrieve data.
                                                                	Config           *IndexerConfig
                                                                	ChtNum, BlockNum uint64
                                                                	ChtRoot          common.Hash
                                                                	Header           *types.Header
                                                                	Td               *big.Int
                                                                	Proof            *NodeSet
                                                                }

                                                                  ChtRequest 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 // references storage trie of the account
                                                                    	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 IndexerConfig

                                                                        type IndexerConfig struct {
                                                                        	// The block frequency for creating CHTs.
                                                                        	ChtSize uint64
                                                                        
                                                                        	// The number of confirmations needed to generate/accept a canonical hash help trie.
                                                                        	ChtConfirms uint64
                                                                        
                                                                        	// The block frequency for creating new bloom bits.
                                                                        	BloomSize uint64
                                                                        
                                                                        	// The number of confirmation needed before a bloom section is considered probably final and its rotated bits
                                                                        	// are calculated.
                                                                        	BloomConfirms uint64
                                                                        
                                                                        	// The block frequency for creating BloomTrie.
                                                                        	BloomTrieSize uint64
                                                                        
                                                                        	// The number of confirmations needed to generate/accept a bloom trie.
                                                                        	BloomTrieConfirms uint64
                                                                        }

                                                                          IndexerConfig includes a set of configs for chain indexers.

                                                                          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, engine consensus.Engine, checkpoint *params.TrustedCheckpoint) (*LightChain, error)

                                                                              NewLightChain returns a fully initialised light chain using information available in the database. It initialises the default Ethereum header validator.

                                                                              func (*LightChain) AddTrustedCheckpoint

                                                                              func (lc *LightChain) AddTrustedCheckpoint(cp *params.TrustedCheckpoint)

                                                                                AddTrustedCheckpoint adds a trusted checkpoint to the blockchain

                                                                                func (*LightChain) Config

                                                                                func (lc *LightChain) Config() *params.ChainConfig

                                                                                  Config retrieves the header chain's chain configuration.

                                                                                  func (*LightChain) CurrentHeader

                                                                                  func (lc *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) DisableCheckFreq

                                                                                    func (lc *LightChain) DisableCheckFreq()

                                                                                      DisableCheckFreq disables header validation. This is used for ultralight mode.

                                                                                      func (*LightChain) EnableCheckFreq

                                                                                      func (lc *LightChain) EnableCheckFreq()

                                                                                        EnableCheckFreq enables header validation.

                                                                                        func (*LightChain) Engine

                                                                                        func (lc *LightChain) Engine() consensus.Engine

                                                                                          Engine retrieves the light chain's consensus engine.

                                                                                          func (*LightChain) GasLimit

                                                                                          func (lc *LightChain) GasLimit() uint64

                                                                                            GasLimit returns the gas limit of the current HEAD block.

                                                                                            func (*LightChain) Genesis

                                                                                            func (lc *LightChain) Genesis() *types.Block

                                                                                              Genesis returns the genesis block

                                                                                              func (*LightChain) GetAncestor

                                                                                              func (lc *LightChain) GetAncestor(hash common.Hash, number, ancestor uint64, maxNonCanonical *uint64) (common.Hash, uint64)

                                                                                                GetAncestor retrieves the Nth ancestor of a given block. It assumes that either the given block or a close ancestor of it is canonical. maxNonCanonical points to a downwards counter limiting the number of blocks to be individually checked before we reach the canonical chain.

                                                                                                Note: ancestor == 0 returns the same block, 1 returns its parent and so on.

                                                                                                func (*LightChain) GetBlock

                                                                                                func (lc *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

                                                                                                  func (lc *LightChain) GetBlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)

                                                                                                    GetBlockByHash retrieves a block from the database or ODR service by hash, caching it if found.

                                                                                                    func (*LightChain) GetBlockByNumber

                                                                                                    func (lc *LightChain) GetBlockByNumber(ctx context.Context, number uint64) (*types.Block, error)

                                                                                                      GetBlockByNumber retrieves a block from the database or ODR service by number, caching it (associated with its hash) if found.

                                                                                                      func (*LightChain) GetBlockHashesFromHash

                                                                                                      func (lc *LightChain) GetBlockHashesFromHash(hash common.Hash, max uint64) []common.Hash

                                                                                                        GetBlockHashesFromHash retrieves a number of block hashes starting at a given hash, fetching towards the genesis block.

                                                                                                        func (*LightChain) GetBody

                                                                                                        func (lc *LightChain) GetBody(ctx context.Context, hash common.Hash) (*types.Body, error)

                                                                                                          GetBody retrieves a block body (transactions and uncles) from the database or ODR service by hash, caching it if found.

                                                                                                          func (*LightChain) GetBodyRLP

                                                                                                          func (lc *LightChain) GetBodyRLP(ctx context.Context, hash common.Hash) (rlp.RawValue, error)

                                                                                                            GetBodyRLP retrieves a block body in RLP encoding from the database or ODR service by hash, caching it if found.

                                                                                                            func (*LightChain) GetCanonicalHash

                                                                                                            func (bc *LightChain) GetCanonicalHash(number uint64) common.Hash

                                                                                                              GetCanonicalHash returns the canonical hash for a given block number

                                                                                                              func (*LightChain) GetHeader

                                                                                                              func (lc *LightChain) GetHeader(hash common.Hash, number uint64) *types.Header

                                                                                                                GetHeader retrieves a block header from the database by hash and number, caching it if found.

                                                                                                                func (*LightChain) GetHeaderByHash

                                                                                                                func (lc *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 (lc *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 (lc *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

                                                                                                                      func (lc *LightChain) GetTd(hash common.Hash, number uint64) *big.Int

                                                                                                                        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 (lc *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 (lc *LightChain) HasBlock(hash common.Hash, number uint64) bool

                                                                                                                            HasBlock checks if a block is fully present in the database or not, caching it if present.

                                                                                                                            func (*LightChain) HasHeader

                                                                                                                            func (lc *LightChain) HasHeader(hash common.Hash, number uint64) bool

                                                                                                                              HasHeader checks if a block header is present in the database or not, caching it if present.

                                                                                                                              func (*LightChain) InsertHeaderChain

                                                                                                                              func (lc *LightChain) InsertHeaderChain(chain []*types.Header, checkFreq int) (int, error)

                                                                                                                                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) LockChain

                                                                                                                                func (lc *LightChain) LockChain()

                                                                                                                                  LockChain locks the chain mutex for reading so that multiple canonical hashes can be retrieved while it is guaranteed that they belong to the same version of the chain

                                                                                                                                  func (*LightChain) Odr

                                                                                                                                  func (lc *LightChain) Odr() OdrBackend

                                                                                                                                    Odr returns the ODR backend of the chain

                                                                                                                                    func (*LightChain) Reset

                                                                                                                                    func (lc *LightChain) Reset()

                                                                                                                                      Reset purges the entire blockchain, restoring it to its genesis state.

                                                                                                                                      func (*LightChain) ResetWithGenesisBlock

                                                                                                                                      func (lc *LightChain) ResetWithGenesisBlock(genesis *types.Block)

                                                                                                                                        ResetWithGenesisBlock purges the entire blockchain, restoring it to the specified genesis state.

                                                                                                                                        func (*LightChain) Rollback

                                                                                                                                        func (lc *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 (lc *LightChain) SetHead(head uint64) error

                                                                                                                                            SetHead rewinds the local chain to a new head. Everything above the new head will be deleted and the new one set.

                                                                                                                                            func (*LightChain) StateCache

                                                                                                                                            func (lc *LightChain) StateCache() state.Database

                                                                                                                                            func (*LightChain) Stop

                                                                                                                                            func (lc *LightChain) Stop()

                                                                                                                                              Stop stops the blockchain service. If any imports are currently in progress it will abort them using the procInterrupt.

                                                                                                                                              func (*LightChain) SubscribeChainEvent

                                                                                                                                              func (lc *LightChain) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription

                                                                                                                                                SubscribeChainEvent registers a subscription of ChainEvent.

                                                                                                                                                func (*LightChain) SubscribeChainHeadEvent

                                                                                                                                                func (lc *LightChain) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription

                                                                                                                                                  SubscribeChainHeadEvent registers a subscription of ChainHeadEvent.

                                                                                                                                                  func (*LightChain) SubscribeChainSideEvent

                                                                                                                                                  func (lc *LightChain) SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription

                                                                                                                                                    SubscribeChainSideEvent registers a subscription of ChainSideEvent.

                                                                                                                                                    func (*LightChain) SubscribeLogsEvent

                                                                                                                                                    func (lc *LightChain) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription

                                                                                                                                                      SubscribeLogsEvent implements the interface of filters.Backend LightChain does not send logs events, so return an empty subscription.

                                                                                                                                                      func (*LightChain) SubscribeRemovedLogsEvent

                                                                                                                                                      func (lc *LightChain) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription

                                                                                                                                                        SubscribeRemovedLogsEvent implements the interface of filters.Backend LightChain does not send core.RemovedLogsEvent, so return an empty subscription.

                                                                                                                                                        func (*LightChain) SyncCheckpoint

                                                                                                                                                        func (lc *LightChain) SyncCheckpoint(ctx context.Context, checkpoint *params.TrustedCheckpoint) bool

                                                                                                                                                          SyncCheckpoint fetches the checkpoint point block header according to the checkpoint provided by the remote peer.

                                                                                                                                                          Note if we are running the clique, fetches the last epoch snapshot header which covered by checkpoint.

                                                                                                                                                          func (*LightChain) UnlockChain

                                                                                                                                                          func (lc *LightChain) UnlockChain()

                                                                                                                                                            UnlockChain unlocks the chain mutex

                                                                                                                                                            type NodeList

                                                                                                                                                            type NodeList []rlp.RawValue

                                                                                                                                                              NodeList stores an ordered list of trie nodes. It implements ethdb.KeyValueWriter.

                                                                                                                                                              func (NodeList) DataSize

                                                                                                                                                              func (n NodeList) DataSize() int

                                                                                                                                                                DataSize returns the aggregated data size of nodes in the list

                                                                                                                                                                func (*NodeList) Delete

                                                                                                                                                                func (n *NodeList) Delete(key []byte) error

                                                                                                                                                                  Delete panics as there's no reason to remove a node from the list.

                                                                                                                                                                  func (NodeList) NodeSet

                                                                                                                                                                  func (n NodeList) NodeSet() *NodeSet

                                                                                                                                                                    NodeSet converts the node list to a NodeSet

                                                                                                                                                                    func (*NodeList) Put

                                                                                                                                                                    func (n *NodeList) Put(key []byte, value []byte) error

                                                                                                                                                                      Put stores a new node at the end of the list

                                                                                                                                                                      func (NodeList) Store

                                                                                                                                                                      func (n NodeList) Store(db ethdb.KeyValueWriter)

                                                                                                                                                                        Store writes the contents of the list to the given database

                                                                                                                                                                        type NodeSet

                                                                                                                                                                        type NodeSet struct {
                                                                                                                                                                        	// contains filtered or unexported fields
                                                                                                                                                                        }

                                                                                                                                                                          NodeSet stores a set of trie nodes. It implements trie.Database and can also act as a cache for another trie.Database.

                                                                                                                                                                          func NewNodeSet

                                                                                                                                                                          func NewNodeSet() *NodeSet

                                                                                                                                                                            NewNodeSet creates an empty node set

                                                                                                                                                                            func (*NodeSet) DataSize

                                                                                                                                                                            func (db *NodeSet) DataSize() int

                                                                                                                                                                              DataSize returns the aggregated data size of nodes in the set

                                                                                                                                                                              func (*NodeSet) Delete

                                                                                                                                                                              func (db *NodeSet) Delete(key []byte) error

                                                                                                                                                                                Delete removes a node from the set

                                                                                                                                                                                func (*NodeSet) Get

                                                                                                                                                                                func (db *NodeSet) Get(key []byte) ([]byte, error)

                                                                                                                                                                                  Get returns a stored node

                                                                                                                                                                                  func (*NodeSet) Has

                                                                                                                                                                                  func (db *NodeSet) Has(key []byte) (bool, error)

                                                                                                                                                                                    Has returns true if the node set contains the given key

                                                                                                                                                                                    func (*NodeSet) KeyCount

                                                                                                                                                                                    func (db *NodeSet) KeyCount() int

                                                                                                                                                                                      KeyCount returns the number of nodes in the set

                                                                                                                                                                                      func (*NodeSet) NodeList

                                                                                                                                                                                      func (db *NodeSet) NodeList() NodeList

                                                                                                                                                                                        NodeList converts the node set to a NodeList

                                                                                                                                                                                        func (*NodeSet) Put

                                                                                                                                                                                        func (db *NodeSet) Put(key []byte, value []byte) error

                                                                                                                                                                                          Put stores a new node in the set

                                                                                                                                                                                          func (*NodeSet) Store

                                                                                                                                                                                          func (db *NodeSet) Store(target ethdb.KeyValueWriter)

                                                                                                                                                                                            Store writes the contents of the set to the given database

                                                                                                                                                                                            type OdrBackend

                                                                                                                                                                                            type OdrBackend interface {
                                                                                                                                                                                            	Database() ethdb.Database
                                                                                                                                                                                            	ChtIndexer() *core.ChainIndexer
                                                                                                                                                                                            	BloomTrieIndexer() *core.ChainIndexer
                                                                                                                                                                                            	BloomIndexer() *core.ChainIndexer
                                                                                                                                                                                            	Retrieve(ctx context.Context, req OdrRequest) error
                                                                                                                                                                                            	IndexerConfig() *IndexerConfig
                                                                                                                                                                                            }

                                                                                                                                                                                              OdrBackend is an interface to a backend service that handles ODR retrievals type

                                                                                                                                                                                              type OdrRequest

                                                                                                                                                                                              type OdrRequest interface {
                                                                                                                                                                                              	StoreResult(db ethdb.Database)
                                                                                                                                                                                              }

                                                                                                                                                                                                OdrRequest is an interface for retrieval requests

                                                                                                                                                                                                type ReceiptsRequest

                                                                                                                                                                                                type ReceiptsRequest struct {
                                                                                                                                                                                                	OdrRequest
                                                                                                                                                                                                	Untrusted bool // Indicator whether the result retrieved is trusted or not
                                                                                                                                                                                                	Hash      common.Hash
                                                                                                                                                                                                	Number    uint64
                                                                                                                                                                                                	Header    *types.Header
                                                                                                                                                                                                	Receipts  types.Receipts
                                                                                                                                                                                                }

                                                                                                                                                                                                  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 TrieID

                                                                                                                                                                                                    type TrieID struct {
                                                                                                                                                                                                    	BlockHash, Root common.Hash
                                                                                                                                                                                                    	BlockNumber     uint64
                                                                                                                                                                                                    	AccKey          []byte
                                                                                                                                                                                                    }

                                                                                                                                                                                                      TrieID identifies a state or account storage trie

                                                                                                                                                                                                      func StateTrieID

                                                                                                                                                                                                      func StateTrieID(header *types.Header) *TrieID

                                                                                                                                                                                                        StateTrieID returns a TrieID for a state trie belonging to a certain block header.

                                                                                                                                                                                                        func StorageTrieID

                                                                                                                                                                                                        func StorageTrieID(state *TrieID, addrHash, root common.Hash) *TrieID

                                                                                                                                                                                                          StorageTrieID returns a TrieID for a contract storage trie at a given account of a given state trie. It also requires the root hash of the trie for checking Merkle proofs.

                                                                                                                                                                                                          type TrieRequest

                                                                                                                                                                                                          type TrieRequest struct {
                                                                                                                                                                                                          	OdrRequest
                                                                                                                                                                                                          	Id    *TrieID
                                                                                                                                                                                                          	Key   []byte
                                                                                                                                                                                                          	Proof *NodeSet
                                                                                                                                                                                                          }

                                                                                                                                                                                                            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 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, chain *LightChain, relay TxRelayBackend) *TxPool

                                                                                                                                                                                                                  NewTxPool creates a new light transaction pool

                                                                                                                                                                                                                  func (*TxPool) Add

                                                                                                                                                                                                                  func (pool *TxPool) Add(ctx context.Context, tx *types.Transaction) error

                                                                                                                                                                                                                    Add adds a transaction to the pool if valid and passes it to the tx relay backend

                                                                                                                                                                                                                    func (*TxPool) AddBatch

                                                                                                                                                                                                                    func (pool *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 (pool *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

                                                                                                                                                                                                                        func (pool *TxPool) GetNonce(ctx context.Context, addr common.Address) (uint64, error)

                                                                                                                                                                                                                          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 (pool *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 (pool *TxPool) GetTransactions() (txs types.Transactions, err error)

                                                                                                                                                                                                                              GetTransactions returns all currently processable transactions. The returned slice may be modified by the caller.

                                                                                                                                                                                                                              func (*TxPool) RemoveTransactions

                                                                                                                                                                                                                              func (pool *TxPool) RemoveTransactions(txs types.Transactions)

                                                                                                                                                                                                                                RemoveTransactions removes all given transactions from the pool.

                                                                                                                                                                                                                                func (*TxPool) RemoveTx

                                                                                                                                                                                                                                func (pool *TxPool) RemoveTx(hash common.Hash)

                                                                                                                                                                                                                                  RemoveTx removes the transaction with the given hash from the pool.

                                                                                                                                                                                                                                  func (*TxPool) Stats

                                                                                                                                                                                                                                  func (pool *TxPool) Stats() (pending int)

                                                                                                                                                                                                                                    Stats returns the number of currently pending (locally created) transactions

                                                                                                                                                                                                                                    func (*TxPool) Stop

                                                                                                                                                                                                                                    func (pool *TxPool) Stop()

                                                                                                                                                                                                                                      Stop stops the light transaction pool

                                                                                                                                                                                                                                      func (*TxPool) SubscribeNewTxsEvent

                                                                                                                                                                                                                                      func (pool *TxPool) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription

                                                                                                                                                                                                                                        SubscribeNewTxsEvent registers a subscription of core.NewTxsEvent and starts sending event to the given channel.

                                                                                                                                                                                                                                        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 TxStatus

                                                                                                                                                                                                                                          type TxStatus struct {
                                                                                                                                                                                                                                          	Status core.TxStatus
                                                                                                                                                                                                                                          	Lookup *rawdb.LegacyTxLookupEntry `rlp:"nil"`
                                                                                                                                                                                                                                          	Error  string
                                                                                                                                                                                                                                          }

                                                                                                                                                                                                                                            TxStatus describes the status of a transaction

                                                                                                                                                                                                                                            type TxStatusRequest

                                                                                                                                                                                                                                            type TxStatusRequest struct {
                                                                                                                                                                                                                                            	OdrRequest
                                                                                                                                                                                                                                            	Hashes []common.Hash
                                                                                                                                                                                                                                            	Status []TxStatus
                                                                                                                                                                                                                                            }

                                                                                                                                                                                                                                              TxStatusRequest is the ODR request type for retrieving transaction status

                                                                                                                                                                                                                                              func (*TxStatusRequest) StoreResult

                                                                                                                                                                                                                                              func (req *TxStatusRequest) StoreResult(db ethdb.Database)

                                                                                                                                                                                                                                                StoreResult stores the retrieved data in local database