diff --git a/les/api_backend.go b/les/api_backend.go index f3ce43ae6f..e716eecd64 100644 --- a/les/api_backend.go +++ b/les/api_backend.go @@ -225,7 +225,6 @@ func (b *ClientBackend) ChainDb() ethdb.Database { return b.eth.chainDb } -// EventMux ... func (b *ClientBackend) EventMux() *event.TypeMux { return b.eth.eventMux } @@ -240,12 +239,14 @@ func (b *ClientBackend) ExtRPCEnabled() bool { return b.extRPCEnabled } -// RPCGasCap - return the global gas cap for eth_call over rpc (DoS protection) +// RPCGasCap return the global gas cap for eth_call over rpc (DoS protection) func (b *ClientBackend) RPCGasCap() *big.Int { return b.eth.config.RPCGasCap } -// BloomStatus .. +// BloomStatus returns the number of BloomBitsBlocksClient (the number of blocks a single bloom bit section vector +// contains on the light client side) and sections, (which is the number of processed sections maintained by the indexer +// and also the information about the last header indexed for potential canonical verifications). func (b *ClientBackend) BloomStatus() (uint64, uint64) { if b.eth.bloomIndexer == nil { return 0, 0 @@ -254,7 +255,6 @@ func (b *ClientBackend) BloomStatus() (uint64, uint64) { return params.BloomBitsBlocksClient, sections } -// ServiceFilter ... func (b *ClientBackend) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession) { for i := 0; i < bloomFilterThreads; i++ { go session.Multiplex(bloomRetrievalBatch, bloomRetrievalWait, b.eth.bloomRequests) diff --git a/les/handler.go b/les/handler.go index f0e83785d0..9294695e68 100644 --- a/les/handler.go +++ b/les/handler.go @@ -49,21 +49,21 @@ const ( ethVersion = 63 // equivalent eth version for the downloader - // MaxHeaderFetch - Amount of block headers to be fetched per retrieval request + // MaxHeaderFetch is the maximum number of block headers to be fetched per retrieval request MaxHeaderFetch = 192 - // MaxBodyFetch - Amount of block bodies to be fetched per retrieval request + // MaxBodyFetch is the maximum number of block bodies to be fetched per retrieval request MaxBodyFetch = 32 - // MaxReceiptFetch - Amount of transaction receipts to allow fetching per request + // MaxReceiptFetch is the maximum number of transaction receipts to allow to be fetched per request MaxReceiptFetch = 128 - // MaxCodeFetch - Amount of contract codes to allow fetching per request + // MaxCodeFetch is the maximum number of contract codes to allow to be fetched per request MaxCodeFetch = 64 - // MaxProofsFetch - Amount of merkle proofs to be fetched per retrieval request + // MaxProofsFetch is the maximum number of merkle proofs to be fetched per retrieval request MaxProofsFetch = 64 - // MaxHelperTrieProofsFetch - Amount of merkle proofs to be fetched per retrieval request + // MaxHelperTrieProofsFetch is the maximum number of merkle proofs to be fetched per retrieval request MaxHelperTrieProofsFetch = 64 - // MaxTxSend - Amount of transactions to be send per request + // MaxTxSend is the maximum number of transactions to be sent per request MaxTxSend = 64 - // MaxTxStatus - Amount of transactions to queried per request + // MaxTxStatus is the maximum number of transactions to queried per request MaxTxStatus = 256 disableClientRemovePeer = false @@ -73,7 +73,7 @@ func errResp(code errCode, format string, v ...interface{}) error { return fmt.Errorf("%v - %v", code, fmt.Sprintf(format, v...)) } -// BlockChain - a blockchain +// BlockChain represents a blockchain, offering functions to query and maintain it type BlockChain interface { Config() *params.ChainConfig HasHeader(hash common.Hash, number uint64) bool diff --git a/les/odr.go b/les/odr.go index db642d9e40..4eba7ff3dd 100644 --- a/les/odr.go +++ b/les/odr.go @@ -82,17 +82,17 @@ func (odr *LesOdr) IndexerConfig() *light.IndexerConfig { } const ( - // MsgBlockBodies - block bodies request + // MsgBlockBodies represents a block bodies request MsgBlockBodies = iota - // MsgCode - code request + // MsgCode represents a code request MsgCode - // MsgReceipts - receipts request + // MsgReceipts represents a receipts request MsgReceipts - // MsgProofsV2 - proofs request + // MsgProofsV2 represents a v2 proofs request MsgProofsV2 - // MsgHelperTrieProofs - helper trie proofs request + // MsgHelperTrieProofs represents a helper trie proofs request MsgHelperTrieProofs - // MsgTxStatus - transaction status request + // MsgTxStatus represents a transaction status request MsgTxStatus ) diff --git a/les/odr_requests.go b/les/odr_requests.go index 88b4eb863f..a03cdcbdff 100644 --- a/les/odr_requests.go +++ b/les/odr_requests.go @@ -45,7 +45,7 @@ var ( errUselessNodes = errors.New("useless nodes in merkle proof nodeset") ) -// LesOdrRequest - an on-demand request +// LesOdrRequest represents an on-demand request from a client type LesOdrRequest interface { GetCost(*peer) uint64 CanSend(*peer) bool @@ -53,7 +53,7 @@ type LesOdrRequest interface { Validate(ethdb.Database, *Msg) error } -// LesRequest - generate a LES on demand request from a light one +// LesRequest generates a LES on demand request based on an on-demand request from the 'light' namespace func LesRequest(req light.OdrRequest) LesOdrRequest { switch r := req.(type) { case *light.BlockRequest: @@ -180,14 +180,14 @@ func (r *ReceiptsRequest) Validate(db ethdb.Database, msg *Msg) error { return nil } -// ProofReq - a request for a proof +// ProofReq is a message requesting a proof type ProofReq struct { BHash common.Hash AccKey, Key []byte FromLevel uint } -// TrieRequest - ODR request type for state/storage trie entries, see LesOdrRequest interface +// TrieRequest is an ODR request message for state/storage trie entries, see LesOdrRequest interface type TrieRequest light.TrieRequest // GetCost returns the cost of the given ODR request according to the serving @@ -236,13 +236,13 @@ func (r *TrieRequest) Validate(db ethdb.Database, msg *Msg) error { return nil } -// CodeReq - a request for contract code +// CodeReq a request for contract code type CodeReq struct { BHash common.Hash AccKey []byte } -// CodeRequest - ODR request type for node data (used for retrieving contract code), see LesOdrRequest interface +// CodeRequest is an ODR request type for code (used for retrieving contract code) type CodeRequest light.CodeRequest // GetCost returns the cost of the given ODR request according to the serving @@ -301,7 +301,7 @@ const ( auxHeader = 2 ) -// HelperTrieReq - a request for part of a trie +// HelperTrieReq is a request for part of a trie type HelperTrieReq struct { Type uint TrieIdx uint64 @@ -309,13 +309,13 @@ type HelperTrieReq struct { FromLevel, AuxReq uint } -// HelperTrieResps - response to HelperTrieReq, providing merkle proofs +// HelperTrieResps response to HelperTrieReq, providing merkle proofs type HelperTrieResps struct { // describes all responses, not just a single one Proofs light.NodeList AuxData [][]byte } -// ChtRequest - ODR request type for requesting headers by Canonical Hash Trie, see LesOdrRequest interface +// ChtRequest is an ODR request type for requesting headers by Canonical Hash Trie type ChtRequest light.ChtRequest // GetCost returns the cost of the given ODR request according to the serving @@ -399,12 +399,10 @@ func (r *ChtRequest) Validate(db ethdb.Database, msg *Msg) error { return nil } -// BloomReq - type BloomReq struct { BloomTrieNum, BitIdx, SectionIndex, FromLevel uint64 } -// BloomRequest - ODR request type for requesting headers by Canonical Hash Trie, see LesOdrRequest interface type BloomRequest light.BloomRequest // GetCost returns the cost of the given ODR request according to the serving diff --git a/les/protocol.go b/les/protocol.go index cd397a118a..5823c8968e 100644 --- a/les/protocol.go +++ b/les/protocol.go @@ -93,35 +93,20 @@ var requests = map[uint64]requestInfo{ type errCode int const ( - // ErrMsgTooLarge - message too large ErrMsgTooLarge = iota - // ErrDecode - decode error ErrDecode - // ErrInvalidMsgCode - invalid message error ErrInvalidMsgCode - // ErrProtocolVersionMismatch - mismatched protocol version ErrProtocolVersionMismatch - // ErrNetworkIDMismatch - wrong network id ErrNetworkIDMismatch - // ErrGenesisBlockMismatch - incompatible genesis blocks ErrGenesisBlockMismatch - // ErrNoStatusMsg - ErrNoStatusMsg - // ErrExtraStatusMsg - ErrExtraStatusMsg - // ErrSuspendedPeer - ErrSuspendedPeer - // ErrUselessPeer - ErrUselessPeer - // ErrRequestRejected - ErrRequestRejected - // ErrUnexpectedResponse - ErrUnexpectedResponse - // ErrInvalidResponse - ErrInvalidResponse - // ErrTooManyTimeouts - ErrTooManyTimeouts - // ErrMissingKey - ErrMissingKey ) diff --git a/les/server.go b/les/server.go index 6530cfc32e..20506ebbe3 100644 --- a/les/server.go +++ b/les/server.go @@ -37,7 +37,7 @@ import ( const bufLimitRatio = 6000 // fixed bufLimit/MRR ratio -// LesServer - a node service running a LES server +// LesServer is a node service running a LES server type LesServer struct { lesCommons @@ -57,7 +57,7 @@ type LesServer struct { priorityClientPool *priorityClientPool } -// NewLesServer - ctor creating a LES server node service +// NewLesServer creates a LES server node service func NewLesServer(eth *eth.Ethereum, config *eth.Config) (*LesServer, error) { quitSync := make(chan struct{}) pm, err := NewProtocolManager( @@ -132,7 +132,7 @@ func NewLesServer(eth *eth.Ethereum, config *eth.Config) (*LesServer, error) { return srv, nil } -// APIs - the RPC APIs offered by this server +// APIs lists the RPC APIs offered by this server func (s *LesServer) APIs() []rpc.API { return []rpc.API{ { @@ -186,7 +186,7 @@ func (s *LesServer) startEventLoop() { }() } -// Protocols - rlpx capabilities offered by this LES server +// Protocols lists the rlpx capabilities offered by this LES server func (s *LesServer) Protocols() []p2p.Protocol { return s.makeProtocols(ServerProtocolVersions) } @@ -235,7 +235,7 @@ func (s *LesServer) Start(srvr *p2p.Server) error { return nil } -// SetBloomBitsIndexer - adds the bloombits indexer as a child indexer to the bloomtrie indexer +// SetBloomBitsIndexer adds the bloombits indexer as a child indexer to the bloomtrie indexer func (s *LesServer) SetBloomBitsIndexer(bloomIndexer *core.ChainIndexer) { bloomIndexer.AddChildIndexer(s.bloomTrieIndexer) }