Documentation ¶
Overview ¶
Package les implements the Light Ethereum Subprotocol.
Index ¶
- Constants
- Variables
- func NewFuzzerPeer(version int) (p *clientPeer, closer func())
- type BlockRequest
- type BloomReq
- type BloomRequest
- type ChtRequest
- type CodeData
- type CodeReq
- type CodeRequest
- type Decoder
- type GatewayFeeInformation
- type GetBlockBodiesPacket
- type GetBlockHeadersData
- type GetBlockHeadersPacket
- type GetCodePacket
- type GetEtherbasePacket
- type GetGatewayFeePacket
- type GetHelperTrieProofsPacket
- type GetProofsPacket
- type GetReceiptsPacket
- type GetTxStatusPacket
- type HeaderRequest
- type HelperTrieReq
- type HelperTrieResps
- type LesApiBackend
- func (b *LesApiBackend) AccountManager() *accounts.Manager
- func (b *LesApiBackend) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
- func (b *LesApiBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error)
- func (b *LesApiBackend) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Block, error)
- func (b *LesApiBackend) BloomStatus() (uint64, uint64)
- func (b *LesApiBackend) ChainConfig() *params.ChainConfig
- func (b *LesApiBackend) ChainDb() ethdb.Database
- func (b *LesApiBackend) CurrentBlock() *types.Block
- func (b *LesApiBackend) CurrentGasPriceMinimum(ctx context.Context, currencyAddress *common.Address) (*big.Int, error)
- func (b *LesApiBackend) CurrentHeader() *types.Header
- func (b *LesApiBackend) Downloader() *downloader.Downloader
- func (b *LesApiBackend) Engine() consensus.Engine
- func (b *LesApiBackend) ExtRPCEnabled() bool
- func (b *LesApiBackend) GasPriceMinimumForHeader(ctx context.Context, currencyAddress *common.Address, header *types.Header) (*big.Int, error)
- func (b *LesApiBackend) GatewayFee() *big.Int
- func (b *LesApiBackend) GatewayFeeRecipient() common.Address
- func (b *LesApiBackend) GetBlockGasLimit(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) uint64
- func (b *LesApiBackend) GetEVM(ctx context.Context, msg core.Message, state *state.StateDB, ...) (*vm.EVM, func() error, error)
- func (b *LesApiBackend) GetIntrinsicGasForAlternativeFeeCurrency(ctx context.Context) uint64
- func (b *LesApiBackend) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log, error)
- func (b *LesApiBackend) GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error)
- func (b *LesApiBackend) GetPoolTransaction(txHash common.Hash) *types.Transaction
- func (b *LesApiBackend) GetPoolTransactions() (types.Transactions, error)
- func (b *LesApiBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error)
- func (b *LesApiBackend) GetTd(ctx context.Context, hash common.Hash) *big.Int
- func (b *LesApiBackend) GetTransaction(ctx context.Context, txHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error)
- func (b *LesApiBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
- func (b *LesApiBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error)
- func (b *LesApiBackend) HeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Header, error)
- func (b *LesApiBackend) NewEVMRunner(header *types.Header, state vm.StateDB) vm.EVMRunner
- func (b *LesApiBackend) PendingBlockAndReceipts() (*types.Block, types.Receipts)
- func (b *LesApiBackend) ProtocolVersion() int
- func (b *LesApiBackend) RPCGasCap() uint64
- func (b *LesApiBackend) RPCTxFeeCap() float64
- func (b *LesApiBackend) RemoveTx(txHash common.Hash)
- func (b *LesApiBackend) SendTx(ctx context.Context, signedTx *types.Transaction) error
- func (b *LesApiBackend) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession)
- func (b *LesApiBackend) SetHead(number uint64)
- func (b *LesApiBackend) StateAndHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*state.StateDB, *types.Header, error)
- func (b *LesApiBackend) StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*state.StateDB, *types.Header, error)
- func (b *LesApiBackend) StateAtBlock(ctx context.Context, block *types.Block, reexec uint64, base *state.StateDB, ...) (*state.StateDB, error)
- func (b *LesApiBackend) StateAtTransaction(ctx context.Context, block *types.Block, txIndex int, reexec uint64) (core.Message, vm.BlockContext, vm.EVMRunner, *state.StateDB, error)
- func (b *LesApiBackend) Stats() (pending int, queued int)
- func (b *LesApiBackend) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription
- func (b *LesApiBackend) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription
- func (b *LesApiBackend) SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription
- func (b *LesApiBackend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription
- func (b *LesApiBackend) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription
- func (b *LesApiBackend) SubscribePendingLogsEvent(ch chan<- []*types.Log) event.Subscription
- func (b *LesApiBackend) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription
- func (b *LesApiBackend) SuggestGasTipCap(ctx context.Context, currencyAddress *common.Address) (*big.Int, error)
- func (b *LesApiBackend) SuggestPrice(ctx context.Context, currencyAddress *common.Address) (*big.Int, error)
- func (b *LesApiBackend) TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
- func (b *LesApiBackend) TxPoolContentFrom(addr common.Address) (types.Transactions, types.Transactions)
- func (b *LesApiBackend) UnprotectedAllowed() bool
- func (b *LesApiBackend) VmRunnerAtHeader(header *types.Header, state *state.StateDB) vm.EVMRunner
- type LesOdr
- func (odr *LesOdr) BloomIndexer() *core.ChainIndexer
- func (odr *LesOdr) BloomTrieIndexer() *core.ChainIndexer
- func (odr *LesOdr) ChtIndexer() *core.ChainIndexer
- func (odr *LesOdr) Database() ethdb.Database
- func (odr *LesOdr) IndexerConfig() *light.IndexerConfig
- func (odr *LesOdr) Retrieve(ctx context.Context, req light.OdrRequest) (err error)
- func (odr *LesOdr) RetrieveTxStatus(ctx context.Context, req *light.TxStatusRequest) error
- func (odr *LesOdr) SetIndexers(chtIndexer, bloomTrieIndexer, bloomIndexer *core.ChainIndexer)
- func (odr *LesOdr) Stop()
- type LesOdrRequest
- type LesServer
- type LightChainReader
- func (lcr *LightChainReader) Config() *params.ChainConfig
- func (lcr *LightChainReader) CurrentHeader() *types.Header
- func (lcr *LightChainReader) GetBlock(hash common.Hash, number uint64) *types.Block
- func (lcr *LightChainReader) GetHeader(hash common.Hash, number uint64) *types.Header
- func (lcr *LightChainReader) GetHeaderByHash(hash common.Hash) *types.Header
- func (lcr *LightChainReader) GetHeaderByNumber(number uint64) *types.Header
- func (lcr *LightChainReader) NewEVMRunner(header *types.Header, state vm.StateDB) vm.EVMRunner
- func (lcr *LightChainReader) NewEVMRunnerForCurrentBlock() (vm.EVMRunner, error)
- type LightDummyAPI
- type LightEthereum
- func (s *LightEthereum) APIs() []rpc.API
- func (s *LightEthereum) BlockChain() *light.LightChain
- func (s *LightEthereum) Downloader() *downloader.Downloader
- func (s *LightEthereum) Engine() consensus.Engine
- func (s *LightEthereum) EventMux() *event.TypeMux
- func (s *LightEthereum) GetRandomPeerEtherbase() common.Address
- func (s *LightEthereum) LesVersion() int
- func (s *LightEthereum) Protocols() []p2p.Protocol
- func (s *LightEthereum) ResetWithGenesisBlock(gb *types.Block)
- func (s *LightEthereum) ServerPool() *vfc.ServerPool
- func (s *LightEthereum) Start() error
- func (s *LightEthereum) Stop() error
- func (s *LightEthereum) TxPool() *light.TxPool
- func (s *LightEthereum) VfluxRequest(n *enode.Node, reqs vflux.Requests) vflux.Replies
- type Msg
- type NodeInfo
- type PeerInfo
- type PrivateDebugAPI
- type PrivateLightAPI
- type PrivateLightClientAPI
- type PrivateLightServerAPI
- func (api *PrivateLightServerAPI) AddBalance(node string, amount int64) (balance [2]uint64, err error)
- func (api *PrivateLightServerAPI) Benchmark(setups []map[string]interface{}, passCount, length int) ([]map[string]interface{}, error)
- func (api *PrivateLightServerAPI) ClientInfo(nodes []string) map[enode.ID]map[string]interface{}
- func (api *PrivateLightServerAPI) GatewayFee() (gf *big.Int, err error)
- func (api *PrivateLightServerAPI) GatewayFeeRecipient() (eb common.Address, err error)
- func (api *PrivateLightServerAPI) PriorityClientInfo(start, stop enode.ID, maxCount int) map[enode.ID]map[string]interface{}
- func (api *PrivateLightServerAPI) ServerInfo() map[string]interface{}
- func (api *PrivateLightServerAPI) SetClientParams(nodes []string, params map[string]interface{}) error
- func (api *PrivateLightServerAPI) SetConnectedBias(bias time.Duration) error
- func (api *PrivateLightServerAPI) SetDefaultParams(params map[string]interface{}) error
- func (api *PrivateLightServerAPI) SetGatewayFee(gf *big.Int) error
- func (api *PrivateLightServerAPI) SetGatewayFeeRecipient(etherbase common.Address) error
- type ProofReq
- type ReceiptsRequest
- type RequestCostList
- type RequestType
- type SendTxPacket
- type TrieRequest
- type TxStatusRequest
Constants ¶
const ( MsgBlockHeaders = iota MsgBlockBodies MsgCode MsgReceipts MsgProofsV2 MsgHelperTrieProofs MsgTxStatus )
const ( NetworkId = 1 ProtocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message )
const ( // Protocol messages inherited from LPV1 StatusMsg = 0x00 AnnounceMsg = 0x01 GetBlockHeadersMsg = 0x02 BlockHeadersMsg = 0x03 GetBlockBodiesMsg = 0x04 BlockBodiesMsg = 0x05 GetReceiptsMsg = 0x06 ReceiptsMsg = 0x07 GetCodeMsg = 0x0a CodeMsg = 0x0b // Protocol messages introduced in LPV2 GetProofsV2Msg = 0x0f ProofsV2Msg = 0x10 GetHelperTrieProofsMsg = 0x11 HelperTrieProofsMsg = 0x12 SendTxV2Msg = 0x13 GetTxStatusMsg = 0x14 TxStatusMsg = 0x15 // Introduced in Celo v1.0 GetEtherbaseMsg = 0x16 EtherbaseMsg = 0x17 // Protocol messages introduced in LPV3 StopMsg = 0x18 ResumeMsg = 0x19 // Protocol messages to be introduced in LPV4 GetGatewayFeeMsg = 0x1A GatewayFeeMsg = 0x1B )
les protocol message codes
const ( ErrMsgTooLarge = iota ErrDecode ErrInvalidMsgCode ErrProtocolVersionMismatch ErrNetworkIdMismatch ErrGenesisBlockMismatch ErrNoStatusMsg ErrExtraStatusMsg ErrSuspendedPeer ErrUselessPeer ErrRequestRejected ErrUnexpectedResponse ErrInvalidResponse ErrTooManyTimeouts ErrMissingKey ErrForkIDRejected )
const ( MaxHeaderFetch = 192 // Amount of block headers to be fetched per retrieval request MaxBodyFetch = 32 // Amount of block bodies to be fetched per retrieval request MaxReceiptFetch = 128 // Amount of transaction receipts to allow fetching per request MaxCodeFetch = 64 // Amount of contract codes to allow fetching per request MaxProofsFetch = 64 // Amount of merkle proofs to be fetched per retrieval request MaxHelperTrieProofsFetch = 64 // Amount of helper tries to be fetched per retrieval request MaxTxSend = 64 // Amount of transactions to be send per request MaxTxStatus = 256 // Amount of transactions to queried per request MaxEtherbase = 1 MaxGatewayFee = 1 )
Variables ¶
var ( ClientProtocolVersions = []uint{lpv2, lpv3, lpv4, lpv5} ServerProtocolVersions = []uint{lpv2, lpv3, lpv4, lpv5} AdvertiseProtocolVersions = []uint{lpv2} // clients are searching for the first advertised protocol in the list )
Supported versions of the les protocol (first is primary)
var Les3 = map[uint64]RequestType{ GetBlockHeadersMsg: { Name: "block header request", MaxCount: MaxHeaderFetch, InPacketsMeter: miscInHeaderPacketsMeter, InTrafficMeter: miscInHeaderTrafficMeter, OutPacketsMeter: miscOutHeaderPacketsMeter, OutTrafficMeter: miscOutHeaderTrafficMeter, ServingTimeMeter: miscServingTimeHeaderTimer, Handle: handleGetBlockHeaders, }, GetBlockBodiesMsg: { Name: "block bodies request", MaxCount: MaxBodyFetch, InPacketsMeter: miscInBodyPacketsMeter, InTrafficMeter: miscInBodyTrafficMeter, OutPacketsMeter: miscOutBodyPacketsMeter, OutTrafficMeter: miscOutBodyTrafficMeter, ServingTimeMeter: miscServingTimeBodyTimer, Handle: handleGetBlockBodies, }, GetCodeMsg: { Name: "code request", MaxCount: MaxCodeFetch, InPacketsMeter: miscInCodePacketsMeter, InTrafficMeter: miscInCodeTrafficMeter, OutPacketsMeter: miscOutCodePacketsMeter, OutTrafficMeter: miscOutCodeTrafficMeter, ServingTimeMeter: miscServingTimeCodeTimer, Handle: handleGetCode, }, GetReceiptsMsg: { Name: "receipts request", MaxCount: MaxReceiptFetch, InPacketsMeter: miscInReceiptPacketsMeter, InTrafficMeter: miscInReceiptTrafficMeter, OutPacketsMeter: miscOutReceiptPacketsMeter, OutTrafficMeter: miscOutReceiptTrafficMeter, ServingTimeMeter: miscServingTimeReceiptTimer, Handle: handleGetReceipts, }, GetProofsV2Msg: { Name: "les/2 proofs request", MaxCount: MaxProofsFetch, InPacketsMeter: miscInTrieProofPacketsMeter, InTrafficMeter: miscInTrieProofTrafficMeter, OutPacketsMeter: miscOutTrieProofPacketsMeter, OutTrafficMeter: miscOutTrieProofTrafficMeter, ServingTimeMeter: miscServingTimeTrieProofTimer, Handle: handleGetProofs, }, GetHelperTrieProofsMsg: { Name: "helper trie proof request", MaxCount: MaxHelperTrieProofsFetch, InPacketsMeter: miscInHelperTriePacketsMeter, InTrafficMeter: miscInHelperTrieTrafficMeter, OutPacketsMeter: miscOutHelperTriePacketsMeter, OutTrafficMeter: miscOutHelperTrieTrafficMeter, ServingTimeMeter: miscServingTimeHelperTrieTimer, Handle: handleGetHelperTrieProofs, }, SendTxV2Msg: { Name: "new transactions", MaxCount: MaxTxSend, InPacketsMeter: miscInTxsPacketsMeter, InTrafficMeter: miscInTxsTrafficMeter, OutPacketsMeter: miscOutTxsPacketsMeter, OutTrafficMeter: miscOutTxsTrafficMeter, ServingTimeMeter: miscServingTimeTxTimer, Handle: handleSendTx, }, GetTxStatusMsg: { Name: "transaction status query request", MaxCount: MaxTxStatus, InPacketsMeter: miscInTxStatusPacketsMeter, InTrafficMeter: miscInTxStatusTrafficMeter, OutPacketsMeter: miscOutTxStatusPacketsMeter, OutTrafficMeter: miscOutTxStatusTrafficMeter, ServingTimeMeter: miscServingTimeTxStatusTimer, Handle: handleGetTxStatus, }, GetEtherbaseMsg: { Name: "etherbase request", MaxCount: MaxEtherbase, InPacketsMeter: miscInEtherbasePacketsMeter, InTrafficMeter: miscInEtherbaseTrafficMeter, OutPacketsMeter: miscOutEtherbasePacketsMeter, OutTrafficMeter: miscOutEtherbaseTrafficMeter, ServingTimeMeter: miscServingTimeEtherbaseTimer, Handle: handleGetEtherbase, }, GetGatewayFeeMsg: { Name: "gatewayFee request", MaxCount: MaxGatewayFee, InPacketsMeter: miscInGatewayFeePacketsMeter, InTrafficMeter: miscInGatewayFeeTrafficMeter, OutPacketsMeter: miscOutGatewayFeePacketsMeter, OutTrafficMeter: miscOutGatewayFeeTrafficMeter, ServingTimeMeter: miscServingTimeGatewayFeeTimer, Handle: handleGetGatewayFee, }, }
Les3 contains the request types supported by les/2 and les/3
var ProtocolLengths = map[uint]uint64{/* contains filtered or unexported fields */}
Number of implemented message corresponding to different protocol versions.
Functions ¶
func NewFuzzerPeer ¶ added in v1.5.0
func NewFuzzerPeer(version int) (p *clientPeer, closer func())
NewFuzzerPeer creates a client peer for test purposes, and also returns a function to close the peer: this is needed to avoid goroutine leaks in the exec queue.
Types ¶
type BlockRequest ¶
type BlockRequest light.BlockRequest
BlockRequest is the ODR request type for block bodies
func (*BlockRequest) CanSend ¶
func (r *BlockRequest) CanSend(peer *serverPeer) bool
CanSend tells if a certain peer is suitable for serving the given request
func (*BlockRequest) GetCost ¶
func (r *BlockRequest) GetCost(peer *serverPeer) uint64
GetCost returns the cost of the given ODR request according to the serving peer's cost table (implementation of LesOdrRequest)
func (*BlockRequest) Request ¶
func (r *BlockRequest) Request(reqID uint64, peer *serverPeer) error
Request sends an ODR request to the LES network (implementation of LesOdrRequest)
type BloomRequest ¶
type BloomRequest light.BloomRequest
ODR request type for requesting headers by Canonical Hash Trie, see LesOdrRequest interface
func (*BloomRequest) CanSend ¶
func (r *BloomRequest) CanSend(peer *serverPeer) bool
CanSend tells if a certain peer is suitable for serving the given request
func (*BloomRequest) GetCost ¶
func (r *BloomRequest) GetCost(peer *serverPeer) uint64
GetCost returns the cost of the given ODR request according to the serving peer's cost table (implementation of LesOdrRequest)
func (*BloomRequest) Request ¶
func (r *BloomRequest) Request(reqID uint64, peer *serverPeer) error
Request sends an ODR request to the LES network (implementation of LesOdrRequest)
type ChtRequest ¶
type ChtRequest light.ChtRequest
ODR request type for requesting headers by Canonical Hash Trie, see LesOdrRequest interface
func (*ChtRequest) CanSend ¶
func (r *ChtRequest) CanSend(peer *serverPeer) bool
CanSend tells if a certain peer is suitable for serving the given request
func (*ChtRequest) GetCost ¶
func (r *ChtRequest) GetCost(peer *serverPeer) uint64
GetCost returns the cost of the given ODR request according to the serving peer's cost table (implementation of LesOdrRequest)
func (*ChtRequest) Request ¶
func (r *ChtRequest) Request(reqID uint64, peer *serverPeer) error
Request sends an ODR request to the LES network (implementation of LesOdrRequest)
type CodeData ¶
type CodeData []struct { Value []byte }
CodeData is the network response packet for a node data retrieval.
type CodeRequest ¶
type CodeRequest light.CodeRequest
ODR request type for node data (used for retrieving contract code), see LesOdrRequest interface
func (*CodeRequest) CanSend ¶
func (r *CodeRequest) CanSend(peer *serverPeer) bool
CanSend tells if a certain peer is suitable for serving the given request
func (*CodeRequest) GetCost ¶
func (r *CodeRequest) GetCost(peer *serverPeer) uint64
GetCost returns the cost of the given ODR request according to the serving peer's cost table (implementation of LesOdrRequest)
func (*CodeRequest) Request ¶
func (r *CodeRequest) Request(reqID uint64, peer *serverPeer) error
Request sends an ODR request to the LES network (implementation of LesOdrRequest)
type Decoder ¶ added in v1.5.0
type Decoder interface {
Decode(val interface{}) error
}
Decoder is implemented by the messages passed to the handler functions
type GatewayFeeInformation ¶
type GetBlockBodiesPacket ¶ added in v1.5.0
GetBlockBodiesPacket represents a block body request
type GetBlockHeadersData ¶ added in v1.5.0
type GetBlockHeadersData struct { Origin hashOrNumber // Block from which to retrieve headers Amount uint64 // Maximum number of headers to retrieve Skip uint64 // Blocks to skip between consecutive headers Reverse bool // Query direction (false = rising towards latest, true = falling towards genesis) }
GetBlockHeadersData represents a block header query (the request ID is not included)
type GetBlockHeadersPacket ¶ added in v1.5.0
type GetBlockHeadersPacket struct { ReqID uint64 Query GetBlockHeadersData }
GetBlockHeadersPacket represents a block header request
type GetCodePacket ¶ added in v1.5.0
GetCodePacket represents a contract code request
type GetEtherbasePacket ¶ added in v1.5.0
type GetEtherbasePacket struct {
ReqID uint64
}
GetEtherbasePacket represents a etherbase request
type GetGatewayFeePacket ¶ added in v1.5.0
type GetGatewayFeePacket struct {
ReqID uint64
}
GetGatewayFeePacket represents a gateway fee request
type GetHelperTrieProofsPacket ¶ added in v1.5.0
type GetHelperTrieProofsPacket struct { ReqID uint64 Reqs []HelperTrieReq }
GetHelperTrieProofsPacket represents a helper trie proof request
type GetProofsPacket ¶ added in v1.5.0
GetProofsPacket represents a proof request
type GetReceiptsPacket ¶ added in v1.5.0
GetReceiptsPacket represents a block receipts request
type GetTxStatusPacket ¶ added in v1.5.0
GetTxStatusPacket represents a transaction status query
type HeaderRequest ¶
type HeaderRequest light.HeaderRequest
BlockRequest is the ODR request type for block headers
func (*HeaderRequest) CanSend ¶
func (r *HeaderRequest) CanSend(peer *serverPeer) bool
CanSend tells if a certain peer is suitable for serving the given request
func (*HeaderRequest) GetCost ¶
func (r *HeaderRequest) GetCost(peer *serverPeer) uint64
GetCost returns the cost of the given ODR request according to the serving peer's cost table (implementation fo LesOdrRequest)
func (*HeaderRequest) Request ¶
func (r *HeaderRequest) Request(reqId uint64, peer *serverPeer) error
Request sends an ODR request to the LES network (implementation of LesOdrRequest)
type HelperTrieReq ¶
type HelperTrieResps ¶
type LesApiBackend ¶
type LesApiBackend struct {
// contains filtered or unexported fields
}
func (*LesApiBackend) AccountManager ¶
func (b *LesApiBackend) AccountManager() *accounts.Manager
func (*LesApiBackend) BlockByHash ¶
func (*LesApiBackend) BlockByNumber ¶
func (b *LesApiBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error)
func (*LesApiBackend) BlockByNumberOrHash ¶
func (b *LesApiBackend) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Block, error)
func (*LesApiBackend) BloomStatus ¶
func (b *LesApiBackend) BloomStatus() (uint64, uint64)
func (*LesApiBackend) ChainConfig ¶
func (b *LesApiBackend) ChainConfig() *params.ChainConfig
func (*LesApiBackend) ChainDb ¶
func (b *LesApiBackend) ChainDb() ethdb.Database
func (*LesApiBackend) CurrentBlock ¶
func (b *LesApiBackend) CurrentBlock() *types.Block
func (*LesApiBackend) CurrentGasPriceMinimum ¶ added in v1.5.0
func (*LesApiBackend) CurrentHeader ¶ added in v1.4.0
func (b *LesApiBackend) CurrentHeader() *types.Header
func (*LesApiBackend) Downloader ¶
func (b *LesApiBackend) Downloader() *downloader.Downloader
func (*LesApiBackend) Engine ¶ added in v1.4.0
func (b *LesApiBackend) Engine() consensus.Engine
func (*LesApiBackend) ExtRPCEnabled ¶
func (b *LesApiBackend) ExtRPCEnabled() bool
func (*LesApiBackend) GasPriceMinimumForHeader ¶ added in v1.5.0
func (*LesApiBackend) GatewayFee ¶
func (b *LesApiBackend) GatewayFee() *big.Int
func (*LesApiBackend) GatewayFeeRecipient ¶
func (b *LesApiBackend) GatewayFeeRecipient() common.Address
func (*LesApiBackend) GetBlockGasLimit ¶ added in v1.4.0
func (b *LesApiBackend) GetBlockGasLimit(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) uint64
func (*LesApiBackend) GetIntrinsicGasForAlternativeFeeCurrency ¶ added in v1.4.0
func (b *LesApiBackend) GetIntrinsicGasForAlternativeFeeCurrency(ctx context.Context) uint64
func (*LesApiBackend) GetPoolNonce ¶
func (*LesApiBackend) GetPoolTransaction ¶
func (b *LesApiBackend) GetPoolTransaction(txHash common.Hash) *types.Transaction
func (*LesApiBackend) GetPoolTransactions ¶
func (b *LesApiBackend) GetPoolTransactions() (types.Transactions, error)
func (*LesApiBackend) GetReceipts ¶
func (*LesApiBackend) GetTransaction ¶
func (*LesApiBackend) HeaderByHash ¶
func (*LesApiBackend) HeaderByNumber ¶
func (b *LesApiBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error)
func (*LesApiBackend) HeaderByNumberOrHash ¶
func (b *LesApiBackend) HeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Header, error)
func (*LesApiBackend) NewEVMRunner ¶ added in v1.4.0
func (*LesApiBackend) PendingBlockAndReceipts ¶ added in v1.5.0
func (b *LesApiBackend) PendingBlockAndReceipts() (*types.Block, types.Receipts)
func (*LesApiBackend) ProtocolVersion ¶
func (b *LesApiBackend) ProtocolVersion() int
func (*LesApiBackend) RPCGasCap ¶
func (b *LesApiBackend) RPCGasCap() uint64
func (*LesApiBackend) RPCTxFeeCap ¶ added in v1.4.0
func (b *LesApiBackend) RPCTxFeeCap() float64
func (*LesApiBackend) RemoveTx ¶
func (b *LesApiBackend) RemoveTx(txHash common.Hash)
func (*LesApiBackend) SendTx ¶
func (b *LesApiBackend) SendTx(ctx context.Context, signedTx *types.Transaction) error
func (*LesApiBackend) ServiceFilter ¶
func (b *LesApiBackend) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession)
func (*LesApiBackend) SetHead ¶
func (b *LesApiBackend) SetHead(number uint64)
func (*LesApiBackend) StateAndHeaderByNumber ¶
func (b *LesApiBackend) StateAndHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*state.StateDB, *types.Header, error)
func (*LesApiBackend) StateAndHeaderByNumberOrHash ¶
func (b *LesApiBackend) StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*state.StateDB, *types.Header, error)
func (*LesApiBackend) StateAtBlock ¶ added in v1.5.0
func (*LesApiBackend) StateAtTransaction ¶ added in v1.5.0
func (*LesApiBackend) Stats ¶
func (b *LesApiBackend) Stats() (pending int, queued int)
func (*LesApiBackend) SubscribeChainEvent ¶
func (b *LesApiBackend) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription
func (*LesApiBackend) SubscribeChainHeadEvent ¶
func (b *LesApiBackend) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription
func (*LesApiBackend) SubscribeChainSideEvent ¶
func (b *LesApiBackend) SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription
func (*LesApiBackend) SubscribeLogsEvent ¶
func (b *LesApiBackend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription
func (*LesApiBackend) SubscribeNewTxsEvent ¶
func (b *LesApiBackend) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription
func (*LesApiBackend) SubscribePendingLogsEvent ¶
func (b *LesApiBackend) SubscribePendingLogsEvent(ch chan<- []*types.Log) event.Subscription
func (*LesApiBackend) SubscribeRemovedLogsEvent ¶
func (b *LesApiBackend) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription
func (*LesApiBackend) SuggestGasTipCap ¶ added in v1.5.0
func (*LesApiBackend) SuggestPrice ¶
func (*LesApiBackend) TxPoolContent ¶
func (b *LesApiBackend) TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
func (*LesApiBackend) TxPoolContentFrom ¶ added in v1.5.0
func (b *LesApiBackend) TxPoolContentFrom(addr common.Address) (types.Transactions, types.Transactions)
func (*LesApiBackend) UnprotectedAllowed ¶ added in v1.5.0
func (b *LesApiBackend) UnprotectedAllowed() bool
func (*LesApiBackend) VmRunnerAtHeader ¶ added in v1.5.0
type LesOdr ¶
type LesOdr struct {
// contains filtered or unexported fields
}
LesOdr implements light.OdrBackend
func NewLesOdr ¶
func NewLesOdr(db ethdb.Database, config *light.IndexerConfig, peers *serverPeerSet, retriever *retrieveManager) *LesOdr
func (*LesOdr) BloomIndexer ¶
func (odr *LesOdr) BloomIndexer() *core.ChainIndexer
BloomIndexer returns the bloombits chain indexer
func (*LesOdr) BloomTrieIndexer ¶
func (odr *LesOdr) BloomTrieIndexer() *core.ChainIndexer
BloomTrieIndexer returns the bloom trie chain indexer
func (*LesOdr) ChtIndexer ¶
func (odr *LesOdr) ChtIndexer() *core.ChainIndexer
ChtIndexer returns the CHT chain indexer
func (*LesOdr) IndexerConfig ¶
func (odr *LesOdr) IndexerConfig() *light.IndexerConfig
IndexerConfig returns the indexer config.
func (*LesOdr) Retrieve ¶
Retrieve tries to fetch an object from the LES network. It's a common API for most of the LES requests except for the TxStatusRequest which needs the additional retry mechanism. If the network retrieval was successful, it stores the object in local db.
func (*LesOdr) RetrieveTxStatus ¶ added in v1.5.0
RetrieveTxStatus retrieves the transaction status from the LES network. There is no guarantee in the LES protocol that the mined transaction will be retrieved back for sure because of different reasons(the transaction is unindexed, the malicous server doesn't reply it deliberately, etc). Therefore, unretrieved transactions(UNKNOWN) will receive a certain number of retries, thus giving a weak guarantee.
func (*LesOdr) SetIndexers ¶
func (odr *LesOdr) SetIndexers(chtIndexer, bloomTrieIndexer, bloomIndexer *core.ChainIndexer)
SetIndexers adds the necessary chain indexers to the ODR backend
type LesOdrRequest ¶
type LesOdrRequest interface { GetCost(*serverPeer) uint64 CanSend(*serverPeer) bool Request(uint64, *serverPeer) error Validate(ethdb.Database, *Msg) error }
func LesRequest ¶
func LesRequest(req light.OdrRequest) LesOdrRequest
type LesServer ¶
type LesServer struct {
// contains filtered or unexported fields
}
func NewLesServer ¶
func (*LesServer) BroadcastGatewayFeeInfo ¶
This sends messages to light client peers whenever this light server updates gateway fee.
type LightChainReader ¶
type LightChainReader struct {
// contains filtered or unexported fields
}
func (*LightChainReader) Config ¶
func (lcr *LightChainReader) Config() *params.ChainConfig
Config returns the chain configuration.
func (*LightChainReader) CurrentHeader ¶
func (lcr *LightChainReader) CurrentHeader() *types.Header
func (*LightChainReader) GetHeaderByHash ¶
func (lcr *LightChainReader) GetHeaderByHash(hash common.Hash) *types.Header
func (*LightChainReader) GetHeaderByNumber ¶
func (lcr *LightChainReader) GetHeaderByNumber(number uint64) *types.Header
func (*LightChainReader) NewEVMRunner ¶ added in v1.4.0
NewEVMRunner creates the System's EVMRunner for given header & sttate
func (*LightChainReader) NewEVMRunnerForCurrentBlock ¶ added in v1.4.0
func (lcr *LightChainReader) NewEVMRunnerForCurrentBlock() (vm.EVMRunner, error)
NewEVMRunnerForCurrentBlock creates the System's EVMRunner for current block & state
type LightDummyAPI ¶
type LightDummyAPI struct{}
func (*LightDummyAPI) Coinbase ¶
func (s *LightDummyAPI) Coinbase() (common.Address, error)
Coinbase is the address that mining rewards will be send to (alias for Etherbase)
func (*LightDummyAPI) Etherbase ¶
func (s *LightDummyAPI) Etherbase() (common.Address, error)
Etherbase is the address that mining rewards will be send to
func (*LightDummyAPI) Hashrate ¶
func (s *LightDummyAPI) Hashrate() hexutil.Uint
Hashrate returns the POW hashrate
func (*LightDummyAPI) Mining ¶
func (s *LightDummyAPI) Mining() bool
Mining returns an indication if this node is currently mining.
type LightEthereum ¶
type LightEthereum struct { ApiBackend *LesApiBackend // contains filtered or unexported fields }
func (*LightEthereum) APIs ¶
func (s *LightEthereum) APIs() []rpc.API
APIs returns the collection of RPC services the ethereum package offers. NOTE, some of these services probably need to be moved to somewhere else.
func (*LightEthereum) BlockChain ¶
func (s *LightEthereum) BlockChain() *light.LightChain
func (*LightEthereum) Downloader ¶
func (s *LightEthereum) Downloader() *downloader.Downloader
func (*LightEthereum) Engine ¶
func (s *LightEthereum) Engine() consensus.Engine
func (*LightEthereum) EventMux ¶
func (s *LightEthereum) EventMux() *event.TypeMux
func (*LightEthereum) GetRandomPeerEtherbase ¶
func (s *LightEthereum) GetRandomPeerEtherbase() common.Address
func (*LightEthereum) LesVersion ¶
func (s *LightEthereum) LesVersion() int
func (*LightEthereum) Protocols ¶
func (s *LightEthereum) Protocols() []p2p.Protocol
Protocols returns all the currently configured network protocols to start.
func (*LightEthereum) ResetWithGenesisBlock ¶
func (s *LightEthereum) ResetWithGenesisBlock(gb *types.Block)
func (*LightEthereum) ServerPool ¶
func (s *LightEthereum) ServerPool() *vfc.ServerPool
func (*LightEthereum) Start ¶
func (s *LightEthereum) Start() error
Start implements node.Lifecycle, starting all internal goroutines needed by the light ethereum protocol implementation.
func (*LightEthereum) Stop ¶
func (s *LightEthereum) Stop() error
Stop implements node.Lifecycle, terminating all internal goroutines used by the Ethereum protocol.
func (*LightEthereum) TxPool ¶
func (s *LightEthereum) TxPool() *light.TxPool
func (*LightEthereum) VfluxRequest ¶ added in v1.5.0
VfluxRequest sends a batch of requests to the given node through discv5 UDP TalkRequest and returns the responses
type NodeInfo ¶
type NodeInfo struct { Network uint64 `json:"network"` // Ethereum network ID (1=Frontier, 2=Morden, Ropsten=3, Rinkeby=4) Genesis common.Hash `json:"genesis"` // SHA3 hash of the host's genesis block Config *params.ChainConfig `json:"config"` // Chain configuration for the fork rules Head common.Hash `json:"head"` // SHA3 hash of the host's best owned block CHT params.TrustedCheckpoint `json:"cht"` // Trused CHT checkpoint for fast catchup }
NodeInfo represents a short summary of the Ethereum sub-protocol metadata known about the host peer.
type PeerInfo ¶ added in v1.5.0
type PeerInfo struct { Version int `json:"version"` // Ethereum protocol version negotiated Difficulty *big.Int `json:"difficulty"` // Total difficulty of the peer's blockchain Head string `json:"head"` // SHA3 hash of the peer's best owned block }
PeerInfo represents a short summary of the `eth` sub-protocol metadata known about a connected peer.
type PrivateDebugAPI ¶
type PrivateDebugAPI struct {
// contains filtered or unexported fields
}
PrivateDebugAPI provides an API to debug LES light server functionality.
func NewPrivateDebugAPI ¶
func NewPrivateDebugAPI(server *LesServer) *PrivateDebugAPI
NewPrivateDebugAPI creates a new LES light server debug API.
func (*PrivateDebugAPI) FreezeClient ¶
func (api *PrivateDebugAPI) FreezeClient(node string) error
FreezeClient forces a temporary client freeze which normally happens when the server is overloaded
type PrivateLightAPI ¶
type PrivateLightAPI struct {
// contains filtered or unexported fields
}
PrivateLightAPI provides an API to access the LES light server or light client.
func NewPrivateLightAPI ¶
func NewPrivateLightAPI(backend *lesCommons) *PrivateLightAPI
NewPrivateLightAPI creates a new LES service API.
func (*PrivateLightAPI) GetCheckpoint ¶
func (api *PrivateLightAPI) GetCheckpoint(index uint64) ([3]string, error)
GetLocalCheckpoint returns the specific local checkpoint package.
The checkpoint package consists of 3 strings:
result[0], 32 bytes hex encoded latest section head hash result[1], 32 bytes hex encoded latest section canonical hash trie root hash result[2], 32 bytes hex encoded latest section bloom trie root hash
func (*PrivateLightAPI) GetCheckpointContractAddress ¶
func (api *PrivateLightAPI) GetCheckpointContractAddress() (string, error)
GetCheckpointContractAddress returns the contract contract address in hex format.
func (*PrivateLightAPI) LatestCheckpoint ¶
func (api *PrivateLightAPI) LatestCheckpoint() ([4]string, error)
LatestCheckpoint returns the latest local checkpoint package.
The checkpoint package consists of 4 strings:
result[0], hex encoded latest section index result[1], 32 bytes hex encoded latest section head hash result[2], 32 bytes hex encoded latest section canonical hash trie root hash result[3], 32 bytes hex encoded latest section bloom trie root hash
type PrivateLightClientAPI ¶
type PrivateLightClientAPI struct {
// contains filtered or unexported fields
}
API should be for light clients of les protocol
func NewPrivateLightClientAPI ¶
func NewPrivateLightClientAPI(le *LightEthereum) *PrivateLightClientAPI
func (*PrivateLightClientAPI) GatewayFeeCache ¶
func (api *PrivateLightClientAPI) GatewayFeeCache() map[string]*GatewayFeeInformation
func (*PrivateLightClientAPI) RequestPeerGatewayFees ¶
func (api *PrivateLightClientAPI) RequestPeerGatewayFees() error
RequestPeerGatewayFees updates cache by pulling gateway fee peer nodes
func (*PrivateLightClientAPI) SuggestGatewayFee ¶
func (api *PrivateLightClientAPI) SuggestGatewayFee() (*GatewayFeeInformation, error)
SuggestGatewayFee suggests the best light server to choose based on different factors. Currently only minPeerGatewayFee.
type PrivateLightServerAPI ¶
type PrivateLightServerAPI struct {
// contains filtered or unexported fields
}
PrivateLightServerAPI provides an API to access the LES light server.
func NewPrivateLightServerAPI ¶
func NewPrivateLightServerAPI(server *LesServer) *PrivateLightServerAPI
NewPrivateLightServerAPI creates a new LES light server API.
func (*PrivateLightServerAPI) AddBalance ¶
func (api *PrivateLightServerAPI) AddBalance(node string, amount int64) (balance [2]uint64, err error)
AddBalance adds the given amount to the balance of a client if possible and returns the balance before and after the operation
func (*PrivateLightServerAPI) Benchmark ¶
func (api *PrivateLightServerAPI) Benchmark(setups []map[string]interface{}, passCount, length int) ([]map[string]interface{}, error)
Benchmark runs a request performance benchmark with a given set of measurement setups in multiple passes specified by passCount. The measurement time for each setup in each pass is specified in milliseconds by length.
Note: measurement time is adjusted for each pass depending on the previous ones. Therefore a controlled total measurement time is achievable in multiple passes.
func (*PrivateLightServerAPI) ClientInfo ¶
func (api *PrivateLightServerAPI) ClientInfo(nodes []string) map[enode.ID]map[string]interface{}
ClientInfo returns information about clients listed in the ids list or matching the given tags
func (*PrivateLightServerAPI) GatewayFee ¶
func (api *PrivateLightServerAPI) GatewayFee() (gf *big.Int, err error)
GatewayFee returns the current gateway fee of this light server
func (*PrivateLightServerAPI) GatewayFeeRecipient ¶
func (api *PrivateLightServerAPI) GatewayFeeRecipient() (eb common.Address, err error)
func (*PrivateLightServerAPI) PriorityClientInfo ¶
func (api *PrivateLightServerAPI) PriorityClientInfo(start, stop enode.ID, maxCount int) map[enode.ID]map[string]interface{}
PriorityClientInfo returns information about clients with a positive balance in the given ID range (stop excluded). If stop is null then the iterator stops only at the end of the ID space. MaxCount limits the number of results returned. If maxCount limit is applied but there are more potential results then the ID of the next potential result is included in the map with an empty structure assigned to it.
func (*PrivateLightServerAPI) ServerInfo ¶
func (api *PrivateLightServerAPI) ServerInfo() map[string]interface{}
ServerInfo returns global server parameters
func (*PrivateLightServerAPI) SetClientParams ¶
func (api *PrivateLightServerAPI) SetClientParams(nodes []string, params map[string]interface{}) error
SetClientParams sets client parameters for all clients listed in the ids list or all connected clients if the list is empty
func (*PrivateLightServerAPI) SetConnectedBias ¶ added in v1.4.0
func (api *PrivateLightServerAPI) SetConnectedBias(bias time.Duration) error
SetConnectedBias set the connection bias, which is applied to already connected clients So that already connected client won't be kicked out very soon and we can ensure all connected clients can have enough time to request or sync some data. When the input parameter `bias` < 0 (illegal), return error.
func (*PrivateLightServerAPI) SetDefaultParams ¶
func (api *PrivateLightServerAPI) SetDefaultParams(params map[string]interface{}) error
SetDefaultParams sets the default parameters applicable to clients connected in the future
func (*PrivateLightServerAPI) SetGatewayFee ¶
func (api *PrivateLightServerAPI) SetGatewayFee(gf *big.Int) error
SetGatewayFee allows this light server node to set a gateway fee
func (*PrivateLightServerAPI) SetGatewayFeeRecipient ¶
func (api *PrivateLightServerAPI) SetGatewayFeeRecipient(etherbase common.Address) error
SetGatewayFeeRecipient sets the etherbase of the gateway fee recipient
type ReceiptsRequest ¶
type ReceiptsRequest light.ReceiptsRequest
ReceiptsRequest is the ODR request type for block receipts by block hash
func (*ReceiptsRequest) CanSend ¶
func (r *ReceiptsRequest) CanSend(peer *serverPeer) bool
CanSend tells if a certain peer is suitable for serving the given request
func (*ReceiptsRequest) GetCost ¶
func (r *ReceiptsRequest) GetCost(peer *serverPeer) uint64
GetCost returns the cost of the given ODR request according to the serving peer's cost table (implementation of LesOdrRequest)
func (*ReceiptsRequest) Request ¶
func (r *ReceiptsRequest) Request(reqID uint64, peer *serverPeer) error
Request sends an ODR request to the LES network (implementation of LesOdrRequest)
type RequestCostList ¶
type RequestCostList []requestCostListItem
RequestCostList is a list representation of request costs which is used for database storage and communication through the network
type RequestType ¶ added in v1.5.0
type RequestType struct { Name string MaxCount uint64 InPacketsMeter, InTrafficMeter, OutPacketsMeter, OutTrafficMeter metrics.Meter ServingTimeMeter metrics.Timer Handle func(msg Decoder) (serve serveRequestFn, reqID, amount uint64, err error) }
RequestType is a static struct that describes an LES request type and references its handler function.
type SendTxPacket ¶ added in v1.5.0
type SendTxPacket struct { ReqID uint64 Txs []*types.Transaction }
SendTxPacket represents a transaction propagation request
type TrieRequest ¶
type TrieRequest light.TrieRequest
ODR request type for state/storage trie entries, see LesOdrRequest interface
func (*TrieRequest) CanSend ¶
func (r *TrieRequest) CanSend(peer *serverPeer) bool
CanSend tells if a certain peer is suitable for serving the given request
func (*TrieRequest) GetCost ¶
func (r *TrieRequest) GetCost(peer *serverPeer) uint64
GetCost returns the cost of the given ODR request according to the serving peer's cost table (implementation of LesOdrRequest)
func (*TrieRequest) Request ¶
func (r *TrieRequest) Request(reqID uint64, peer *serverPeer) error
Request sends an ODR request to the LES network (implementation of LesOdrRequest)
type TxStatusRequest ¶
type TxStatusRequest light.TxStatusRequest
TxStatusRequest is the ODR request type for transaction status
func (*TxStatusRequest) CanSend ¶
func (r *TxStatusRequest) CanSend(peer *serverPeer) bool
CanSend tells if a certain peer is suitable for serving the given request
func (*TxStatusRequest) GetCost ¶
func (r *TxStatusRequest) GetCost(peer *serverPeer) uint64
GetCost returns the cost of the given ODR request according to the serving peer's cost table (implementation of LesOdrRequest)
func (*TxStatusRequest) Request ¶
func (r *TxStatusRequest) Request(reqID uint64, peer *serverPeer) error
Request sends an ODR request to the LES network (implementation of LesOdrRequest)
Source Files ¶
- api.go
- api_backend.go
- benchmark.go
- bloombits.go
- client.go
- client_handler.go
- commons.go
- costtracker.go
- distributor.go
- enr_entry.go
- fetcher.go
- lightchainreader.go
- metrics.go
- odr.go
- odr_requests.go
- peer.go
- protocol.go
- pruner.go
- retrieve.go
- server.go
- server_handler.go
- server_requests.go
- servingqueue.go
- state_accessor.go
- sync.go
- test_helper.go
- txrelay.go
- ulc.go
Directories ¶
Path | Synopsis |
---|---|
Package checkpointoracle is a wrapper of checkpoint oracle contract with additional rules defined.
|
Package checkpointoracle is a wrapper of checkpoint oracle contract with additional rules defined. |
Package flowcontrol implements a client side flow control mechanism
|
Package flowcontrol implements a client side flow control mechanism |