les

package
v0.0.0-...-ac8b7ce Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2021 License: GPL-3.0 Imports: 53 Imported by: 0

Documentation

Overview

* todo 轻节点API 实现

Package les implements the Light Ethereum Subprotocol.

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

Package les implements the Light Ethereum Subprotocol.

Package les implements the Light Ethereum Subprotocol.

Package les implements the Light Ethereum Subprotocol.

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

Package les implements the Light Ethereum Subprotocol.

Package les implements the Light Ethereum Subprotocol.

Package les implements the Light Ethereum Subprotocol.

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

Package les implements the Light Ethereum Subprotocol.

Package les implements the Light Ethereum Subprotocol.

Index

Constants

View Source
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
	// 每个检索请求将获取的Merkle证明数量
	MaxProofsFetch           = 64  // Amount of merkle proofs to be fetched per retrieval request
	MaxHelperTrieProofsFetch = 64  // Amount of merkle proofs 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

)
View Source
const (
	MsgBlockBodies = iota
	MsgCode
	MsgReceipts
	MsgProofsV1
	MsgProofsV2
	MsgHeaderProofs
	MsgHelperTrieProofs
)
View Source
const (
	NetworkId = 1
	// todo 协议消息大小的最大上限
	ProtocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message
)
View Source
const (
	// Protocol messages belonging to LPV1
	StatusMsg          = 0x00 // P2P 握手信号
	AnnounceMsg        = 0x01 // 拉取header 的hash, num, td 等
	GetBlockHeadersMsg = 0x02 // 拉取Header 的req
	BlockHeadersMsg    = 0x03 // 处理Header拉取的resp
	GetBlockBodiesMsg  = 0x04 // 拉取bodies 的req
	BlockBodiesMsg     = 0x05 // 处理bodies 的resp
	GetReceiptsMsg     = 0x06 // 拉取 receipt的req
	ReceiptsMsg        = 0x07 // 处理 receipt 拉取的resp
	GetProofsV1Msg     = 0x08 // 拉取 merkle proof LPV1  TODO (应该是 (odr *LesOdr) Retrieve 调用过来的)
	ProofsV1Msg        = 0x09 // client处理 LPV1 的 merkle proof 响应
	GetCodeMsg         = 0x0a // 拉取Code的req
	CodeMsg            = 0x0b // 处理Code拉取的resp
	SendTxMsg          = 0x0c // 发出 tx 的广播 LPV1
	GetHeaderProofsMsg = 0x0d // LPV1: 不管是 ChtIndexer的`ChtRequest` 或者是 BloomTrieIndexer的`BloomRequest` 都走这个
	HeaderProofsMsg    = 0x0e // Client 处理 headerProof 的resp
	// Protocol messages belonging to LPV2
	GetProofsV2Msg = 0x0f // 拉取 merkle proof LPV2 TODO (应该是 (odr *LesOdr) Retrieve 调用过来的)
	ProofsV2Msg    = 0x10 // client处理 LPV2 的 merkle proof 响应

	/**
	LES服务器为每32768个块生成CHT,CHT[i]其中包含block 的数据0..i * 32768-1。
	如果客户端知道的根哈希,CHT[i]并希望获取标头号N(其中N < i * 32768),
	则可以通过GetHelperTrieProofs请求获取标头和CHT的相应Merkle证明.
	*/
	GetHelperTrieProofsMsg = 0x11 // LPV2: 不管是 ChtIndexer的`ChtRequest` 或者是 BloomTrieIndexer的`BloomRequest` 都走这个
	HelperTrieProofsMsg    = 0x12 // Client 处理 headerProof 的resp
	SendTxV2Msg            = 0x13 // 发出 tx 的广播 LPV2  (会将 txs 的 status 回应给 client)
	GetTxStatusMsg         = 0x14 // 校验 tx status 的req
	TxStatusMsg            = 0x15 // 校验 tx status 的 resp
)

les protocol message codes

View Source
const (
	ErrMsgTooLarge = iota
	ErrDecode
	ErrInvalidMsgCode
	ErrProtocolVersionMismatch
	ErrNetworkIdMismatch
	ErrGenesisBlockMismatch
	ErrNoStatusMsg
	ErrExtraStatusMsg
	ErrSuspendedPeer
	ErrUselessPeer
	ErrRequestRejected
	ErrUnexpectedResponse
	ErrInvalidResponse
	ErrTooManyTimeouts
	ErrMissingKey
)

Variables

View Source
var (
	ClientProtocolVersions    = []uint{lpv2, lpv1}
	ServerProtocolVersions    = []uint{lpv2, lpv1}
	AdvertiseProtocolVersions = []uint{lpv2} // clients are searching for the first advertised protocol in the list
)

Supported versions of the les protocol (first is primary)

View Source
var ProtocolLengths = map[uint]uint64{/* contains filtered or unexported fields */}

Number of implemented message corresponding to different protocol versions.

Functions

This section is empty.

Types

type BlockChain

type BlockChain interface {
	Config() *params.ChainConfig
	HasHeader(hash common.Hash, number uint64) bool
	GetHeader(hash common.Hash, number uint64) *types.Header
	GetHeaderByHash(hash common.Hash) *types.Header
	CurrentHeader() *types.Header
	GetTd(hash common.Hash, number uint64) *big.Int
	State() (*state.StateDB, error)
	InsertHeaderChain(chain []*types.Header, checkFreq int) (int, error)
	Rollback(chain []common.Hash)
	GetHeaderByNumber(number uint64) *types.Header
	GetAncestor(hash common.Hash, number, ancestor uint64, maxNonCanonical *uint64) (common.Hash, uint64)
	Genesis() *types.Block
	SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription
}

type BlockRequest

type BlockRequest light.BlockRequest

BlockRequest is the ODR request type for block bodies

func (*BlockRequest) CanSend

func (r *BlockRequest) CanSend(peer *peer) bool

CanSend tells if a certain peer is suitable for serving the given request

func (*BlockRequest) GetCost

func (r *BlockRequest) GetCost(peer *peer) 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 *peer) error

Request sends an ODR request to the LES network (implementation of LesOdrRequest)

func (*BlockRequest) Validate

func (r *BlockRequest) Validate(db ethdb.Database, msg *Msg) error

type BloomReq

type BloomReq struct {
	BloomTrieNum, BitIdx, SectionIdx, FromLevel uint64
}

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 *peer) bool

CanSend tells if a certain peer is suitable for serving the given request

func (*BloomRequest) GetCost

func (r *BloomRequest) GetCost(peer *peer) 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 *peer) error

Request sends an ODR request to the LES network (implementation of LesOdrRequest)

func (*BloomRequest) Validate

func (r *BloomRequest) Validate(db ethdb.Database, msg *Msg) error

type ChtReq

type ChtReq struct {
	// ChtNum: 拉取某个 section 中的head num
	// BlockNum: 当前需要拉取的 block header num
	ChtNum, BlockNum uint64
	FromLevel        uint
}

legacy LES/1

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 *peer) bool

CanSend tells if a certain peer is suitable for serving the given request

func (*ChtRequest) GetCost

func (r *ChtRequest) GetCost(peer *peer) 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 *peer) error

Request sends an ODR request to the LES network (implementation of LesOdrRequest)

func (*ChtRequest) Validate

func (r *ChtRequest) Validate(db ethdb.Database, msg *Msg) error

Valid processes an ODR request reply message from the LES network returns true and stores results in memory if the message was a valid reply to the request (implementation of LesOdrRequest) * todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ##################################

todo 超级重要

ChtRequest, 对 HeaderProof 和 HelperTrieProof 的校验及处理

todo 这个,就是最终对 proof 做校验了

todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ##################################

type ChtResp

type ChtResp struct {
	Header *types.Header
	Proof  []rlp.RawValue
}

legacy LES/1

type CodeData

type CodeData []struct {
	Value []byte
}

CodeData is the network response packet for a node data retrieval.

type CodeReq

type CodeReq struct {
	BHash  common.Hash
	AccKey []byte
}

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 *peer) bool

CanSend tells if a certain peer is suitable for serving the given request

func (*CodeRequest) GetCost

func (r *CodeRequest) GetCost(peer *peer) 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 *peer) error

Request sends an ODR request to the LES network (implementation of LesOdrRequest)

func (*CodeRequest) Validate

func (r *CodeRequest) Validate(db ethdb.Database, msg *Msg) error

* todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ##################################

todo 超级重要

CodeRequest, 对 code 的校验及处理

todo 这个,就是最终对 proof 做校验了

todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ##################################

type HelperTrieReq

type HelperTrieReq struct {
	Type              uint
	TrieIdx           uint64
	Key               []byte
	FromLevel, AuxReq uint
}

type HelperTrieResps

type HelperTrieResps struct {
	Proofs  light.NodeList
	AuxData [][]byte
}

type LesApiBackend

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

func (*LesApiBackend) AccountManager

func (b *LesApiBackend) AccountManager() *accounts.Manager

func (*LesApiBackend) BlockByNumber

func (b *LesApiBackend) BlockByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*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) Downloader

func (b *LesApiBackend) Downloader() *downloader.Downloader

func (*LesApiBackend) EventMux

func (b *LesApiBackend) EventMux() *event.TypeMux

func (*LesApiBackend) GetBlock

func (b *LesApiBackend) GetBlock(ctx context.Context, blockHash common.Hash) (*types.Block, error)

func (*LesApiBackend) GetEVM

func (b *LesApiBackend) GetEVM(ctx context.Context, msg core.Message, state *state.StateDB, header *types.Header, vmCfg vm.Config) (*vm.EVM, func() error, error)

func (*LesApiBackend) GetLogs

func (b *LesApiBackend) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log, error)

func (*LesApiBackend) GetPoolNonce

func (b *LesApiBackend) GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error)

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 (b *LesApiBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error)

func (*LesApiBackend) GetTd

func (b *LesApiBackend) GetTd(hash common.Hash) *big.Int

func (*LesApiBackend) HeaderByHash

func (b *LesApiBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)

func (*LesApiBackend) HeaderByNumber

func (b *LesApiBackend) HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error)

TODO light API

func (*LesApiBackend) ProtocolVersion

func (b *LesApiBackend) ProtocolVersion() int

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)

轻节点的 client 端 todo 这个就是实时去拉取 bloom

func (*LesApiBackend) SetHead

func (b *LesApiBackend) SetHead(number uint64)

func (*LesApiBackend) StateAndHeaderByNumber

func (b *LesApiBackend) StateAndHeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*state.StateDB, *types.Header, error)

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

func (b *LesApiBackend) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription

func (*LesApiBackend) SuggestPrice

func (b *LesApiBackend) SuggestPrice(ctx context.Context) (*big.Int, error)

func (*LesApiBackend) TxPoolContent

type LesOdr

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

LesOdr implements light.OdrBackend

func NewLesOdr

func NewLesOdr(db ethdb.Database, retriever *retrieveManager) *LesOdr

func (*LesOdr) BloomIndexer

func (odr *LesOdr) BloomIndexer() *core.ChainIndexer

BloomIndexer returns the bloombits chain indexer

BloomIndexer: 返回Bloombits链索引器

func (*LesOdr) BloomTrieIndexer

func (odr *LesOdr) BloomTrieIndexer() *core.ChainIndexer

BloomTrieIndexer returns the bloom trie chain indexer

BloomTrieIndexer: 返回Bloom Trie链索引器

func (*LesOdr) ChtIndexer

func (odr *LesOdr) ChtIndexer() *core.ChainIndexer

ChtIndexer returns the CHT chain indexer

func (*LesOdr) Database

func (odr *LesOdr) Database() ethdb.Database

Database returns the backing database

func (*LesOdr) Retrieve

func (odr *LesOdr) Retrieve(ctx context.Context, req light.OdrRequest) (err error)

Retrieve tries to fetch an object from the LES network. If the network retrieval was successful, it stores the object in local db.

* Retrieve: 尝试从LES网络中获取对象。 如果网络检索成功,它将对象存储在本地数据库中.

TODO 一般只有两个 Indexer 需要用到 todo 一) BloomTrieIndexer todo 二) ChtIndexer

func (*LesOdr) SetIndexers

func (odr *LesOdr) SetIndexers(chtIndexer, bloomTrieIndexer, bloomIndexer *core.ChainIndexer)

SetIndexers adds the necessary chain indexers to the ODR backend

SetIndexers向ODR backend添加必要的链索引器

func (*LesOdr) Stop

func (odr *LesOdr) Stop()

Stop cancels all pending retrievals

type LesOdrRequest

type LesOdrRequest interface {
	GetCost(*peer) uint64
	CanSend(*peer) bool
	Request(uint64, *peer) error
	Validate(ethdb.Database, *Msg) error
}

func LesRequest

func LesRequest(req light.OdrRequest) LesOdrRequest

type LesServer

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

* 轻节点 的server端实现 (即: 全节点对于 les 的server实现)

func NewLesServer

func NewLesServer(eth *eth.Ethereum, config *eth.Config) (*LesServer, error)

* todo 创建 轻节点的server端

func (*LesServer) Protocols

func (s *LesServer) Protocols() []p2p.Protocol

todo ############################## todo ############################## todo ############################## todo ##############################

todo 启动 轻节点 Server 端

func (*LesServer) SetBloomBitsIndexer

func (s *LesServer) SetBloomBitsIndexer(bloomIndexer *core.ChainIndexer)

添加 BloomBits 子索引器

func (*LesServer) Start

func (s *LesServer) Start(srvr *p2p.Server)

Start starts the LES server

todo 启动 轻节点 Server端

func (*LesServer) Stop

func (s *LesServer) Stop()

Stop stops the LES service

type LesTxRelay

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

peerSetNotify 的一个实现

func NewLesTxRelay

func NewLesTxRelay(ps *peerSet, reqDist *requestDistributor) *LesTxRelay

func (*LesTxRelay) Discard

func (self *LesTxRelay) Discard(hashes []common.Hash)

func (*LesTxRelay) NewHead

func (self *LesTxRelay) NewHead(head common.Hash, mined []common.Hash, rollback []common.Hash)

func (*LesTxRelay) Send

func (self *LesTxRelay) Send(txs types.Transactions)

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 {

	// api的封装
	ApiBackend *LesApiBackend
	// contains filtered or unexported fields
}

func New

func New(ctx *node.ServiceContext, config *eth.Config) (*LightEthereum, error)

* 创建一个 轻节点服务

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

func (s *LightEthereum) LesVersion() int

func (*LightEthereum) Protocols

func (s *LightEthereum) Protocols() []p2p.Protocol

Protocols implements node.Service, returning all the currently configured network protocols to start. todo ############################## todo ############################## todo ############################## todo ############################## todo ############################## todo ############################## todo 启动轻节点 Client 端

func (*LightEthereum) ResetWithGenesisBlock

func (s *LightEthereum) ResetWithGenesisBlock(gb *types.Block)

func (*LightEthereum) Start

func (s *LightEthereum) Start(srvr *p2p.Server) error

Start implements node.Service, starting all internal goroutines needed by the Ethereum protocol implementation.

func (*LightEthereum) Stop

func (s *LightEthereum) Stop() error

Stop implements node.Service, terminating all internal goroutines used by the Ethereum protocol.

func (*LightEthereum) TxPool

func (s *LightEthereum) TxPool() *light.TxPool

type Msg

type Msg struct {
	MsgType int
	ReqID   uint64
	Obj     interface{}
}

Msg encodes a LES message that delivers reply data for a request

type NodeInfo

type NodeInfo struct {
	Network    uint64                  `json:"network"`    // Ethereum network ID (1=Frontier, 2=Morden, Ropsten=3, Rinkeby=4)
	Difficulty *big.Int                `json:"difficulty"` // Total difficulty of the host's blockchain
	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        light.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 ProofReq

type ProofReq struct {

	// 表示需要从那个block 拉取数据
	BHash common.Hash

	// AccKey: 账户的key
	// Key:
	AccKey, Key []byte
	FromLevel   uint
}

* todo 轻节点 拉取merkle证明的 请求

type ProtocolManager

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

func NewProtocolManager

func NewProtocolManager(chainConfig *params.ChainConfig, lightSync bool, networkId uint64, mux *event.TypeMux, engine consensus.Engine, peers *peerSet, blockchain BlockChain, txpool txPool, chainDb ethdb.Database, odr *LesOdr, txrelay *LesTxRelay, serverPool *serverPool, quitSync chan struct{}, wg *sync.WaitGroup) (*ProtocolManager, error)

NewProtocolManager returns a new ethereum sub protocol manager. The Ethereum sub protocol manages peers capable with the ethereum network.

func (*ProtocolManager) Start

func (pm *ProtocolManager) Start(maxPeers int)

* TODO 启动 轻节点的 pm (Server/Client)

func (*ProtocolManager) Stop

func (pm *ProtocolManager) Stop()

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 *peer) bool

CanSend tells if a certain peer is suitable for serving the given request

func (*ReceiptsRequest) GetCost

func (r *ReceiptsRequest) GetCost(peer *peer) 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 *peer) error

Request sends an ODR request to the LES network (implementation of LesOdrRequest)

func (*ReceiptsRequest) Validate

func (r *ReceiptsRequest) Validate(db ethdb.Database, msg *Msg) error

Valid processes an ODR request reply message from the LES network returns true and stores results in memory if the message was a valid reply to the request (implementation of LesOdrRequest)

* todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ##################################

todo 超级重要

ReceiptsRequest, 对 Receipts 的校验及处理

todo 这个,就是最终对 proof 做校验了

todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ##################################

type RequestCostList

type RequestCostList []struct {
	MsgCode, BaseCost, ReqCost uint64
}

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 *peer) bool

CanSend tells if a certain peer is suitable for serving the given request

func (*TrieRequest) GetCost

func (r *TrieRequest) GetCost(peer *peer) 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 *peer) error

Request sends an ODR request to the LES network (implementation of LesOdrRequest)

func (*TrieRequest) Validate

func (r *TrieRequest) Validate(db ethdb.Database, msg *Msg) error

Valid processes an ODR request reply message from the LES network returns true and stores results in memory if the message was a valid reply to the request (implementation of LesOdrRequest)

* todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ##################################

todo 超级重要

TrieRequest, 对 merkle trie Proofs 的校验及处理

todo 这个,就是最终对 proof 做校验了

todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ################################## todo ##################################

Directories

Path Synopsis
* 流量控制 Package flowcontrol implements a client side flow control mechanism
* 流量控制 Package flowcontrol implements a client side flow control mechanism

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL