mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
Correcting documentation format
This commit is contained in:
parent
25b8e8252c
commit
9bfc31a213
6 changed files with 36 additions and 49 deletions
|
|
@ -225,7 +225,6 @@ func (b *ClientBackend) ChainDb() ethdb.Database {
|
||||||
return b.eth.chainDb
|
return b.eth.chainDb
|
||||||
}
|
}
|
||||||
|
|
||||||
// EventMux ...
|
|
||||||
func (b *ClientBackend) EventMux() *event.TypeMux {
|
func (b *ClientBackend) EventMux() *event.TypeMux {
|
||||||
return b.eth.eventMux
|
return b.eth.eventMux
|
||||||
}
|
}
|
||||||
|
|
@ -240,12 +239,14 @@ func (b *ClientBackend) ExtRPCEnabled() bool {
|
||||||
return b.extRPCEnabled
|
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 {
|
func (b *ClientBackend) RPCGasCap() *big.Int {
|
||||||
return b.eth.config.RPCGasCap
|
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) {
|
func (b *ClientBackend) BloomStatus() (uint64, uint64) {
|
||||||
if b.eth.bloomIndexer == nil {
|
if b.eth.bloomIndexer == nil {
|
||||||
return 0, 0
|
return 0, 0
|
||||||
|
|
@ -254,7 +255,6 @@ func (b *ClientBackend) BloomStatus() (uint64, uint64) {
|
||||||
return params.BloomBitsBlocksClient, sections
|
return params.BloomBitsBlocksClient, sections
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServiceFilter ...
|
|
||||||
func (b *ClientBackend) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession) {
|
func (b *ClientBackend) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession) {
|
||||||
for i := 0; i < bloomFilterThreads; i++ {
|
for i := 0; i < bloomFilterThreads; i++ {
|
||||||
go session.Multiplex(bloomRetrievalBatch, bloomRetrievalWait, b.eth.bloomRequests)
|
go session.Multiplex(bloomRetrievalBatch, bloomRetrievalWait, b.eth.bloomRequests)
|
||||||
|
|
|
||||||
|
|
@ -50,21 +50,21 @@ const (
|
||||||
|
|
||||||
ethVersion = 63 // equivalent eth version for the downloader
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
MaxTxSend = 64
|
||||||
// MaxTxStatus - Amount of transactions to queried per request
|
// MaxTxStatus is the maximum number of transactions to queried per request
|
||||||
MaxTxStatus = 256
|
MaxTxStatus = 256
|
||||||
|
|
||||||
disableClientRemovePeer = false
|
disableClientRemovePeer = false
|
||||||
|
|
@ -74,7 +74,7 @@ func errResp(code errCode, format string, v ...interface{}) error {
|
||||||
return fmt.Errorf("%v - %v", code, fmt.Sprintf(format, v...))
|
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 {
|
type BlockChain interface {
|
||||||
Config() *params.ChainConfig
|
Config() *params.ChainConfig
|
||||||
HasHeader(hash common.Hash, number uint64) bool
|
HasHeader(hash common.Hash, number uint64) bool
|
||||||
|
|
|
||||||
12
les/odr.go
12
les/odr.go
|
|
@ -82,17 +82,17 @@ func (odr *LesOdr) IndexerConfig() *light.IndexerConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// MsgBlockBodies - block bodies request
|
// MsgBlockBodies represents a block bodies request
|
||||||
MsgBlockBodies = iota
|
MsgBlockBodies = iota
|
||||||
// MsgCode - code request
|
// MsgCode represents a code request
|
||||||
MsgCode
|
MsgCode
|
||||||
// MsgReceipts - receipts request
|
// MsgReceipts represents a receipts request
|
||||||
MsgReceipts
|
MsgReceipts
|
||||||
// MsgProofsV2 - proofs request
|
// MsgProofsV2 represents a v2 proofs request
|
||||||
MsgProofsV2
|
MsgProofsV2
|
||||||
// MsgHelperTrieProofs - helper trie proofs request
|
// MsgHelperTrieProofs represents a helper trie proofs request
|
||||||
MsgHelperTrieProofs
|
MsgHelperTrieProofs
|
||||||
// MsgTxStatus - transaction status request
|
// MsgTxStatus represents a transaction status request
|
||||||
MsgTxStatus
|
MsgTxStatus
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ var (
|
||||||
errUselessNodes = errors.New("useless nodes in merkle proof nodeset")
|
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 {
|
type LesOdrRequest interface {
|
||||||
GetCost(*peer) uint64
|
GetCost(*peer) uint64
|
||||||
CanSend(*peer) bool
|
CanSend(*peer) bool
|
||||||
|
|
@ -53,7 +53,7 @@ type LesOdrRequest interface {
|
||||||
Validate(ethdb.Database, *Msg) error
|
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 {
|
func LesRequest(req light.OdrRequest) LesOdrRequest {
|
||||||
switch r := req.(type) {
|
switch r := req.(type) {
|
||||||
case *light.BlockRequest:
|
case *light.BlockRequest:
|
||||||
|
|
@ -180,14 +180,14 @@ func (r *ReceiptsRequest) Validate(db ethdb.Database, msg *Msg) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProofReq - a request for a proof
|
// ProofReq is a message requesting a proof
|
||||||
type ProofReq struct {
|
type ProofReq struct {
|
||||||
BHash common.Hash
|
BHash common.Hash
|
||||||
AccKey, Key []byte
|
AccKey, Key []byte
|
||||||
FromLevel uint
|
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
|
type TrieRequest light.TrieRequest
|
||||||
|
|
||||||
// GetCost returns the cost of the given ODR request according to the serving
|
// 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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CodeReq - a request for contract code
|
// CodeReq a request for contract code
|
||||||
type CodeReq struct {
|
type CodeReq struct {
|
||||||
BHash common.Hash
|
BHash common.Hash
|
||||||
AccKey []byte
|
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
|
type CodeRequest light.CodeRequest
|
||||||
|
|
||||||
// GetCost returns the cost of the given ODR request according to the serving
|
// GetCost returns the cost of the given ODR request according to the serving
|
||||||
|
|
@ -301,7 +301,7 @@ const (
|
||||||
auxHeader = 2
|
auxHeader = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
// HelperTrieReq - a request for part of a trie
|
// HelperTrieReq is a request for part of a trie
|
||||||
type HelperTrieReq struct {
|
type HelperTrieReq struct {
|
||||||
Type uint
|
Type uint
|
||||||
TrieIdx uint64
|
TrieIdx uint64
|
||||||
|
|
@ -309,13 +309,13 @@ type HelperTrieReq struct {
|
||||||
FromLevel, AuxReq uint
|
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
|
type HelperTrieResps struct { // describes all responses, not just a single one
|
||||||
Proofs light.NodeList
|
Proofs light.NodeList
|
||||||
AuxData [][]byte
|
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
|
type ChtRequest light.ChtRequest
|
||||||
|
|
||||||
// GetCost returns the cost of the given ODR request according to the serving
|
// 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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// BloomReq -
|
|
||||||
type BloomReq struct {
|
type BloomReq struct {
|
||||||
BloomTrieNum, BitIdx, SectionIndex, FromLevel uint64
|
BloomTrieNum, BitIdx, SectionIndex, FromLevel uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// BloomRequest - ODR request type for requesting headers by Canonical Hash Trie, see LesOdrRequest interface
|
|
||||||
type BloomRequest light.BloomRequest
|
type BloomRequest light.BloomRequest
|
||||||
|
|
||||||
// GetCost returns the cost of the given ODR request according to the serving
|
// GetCost returns the cost of the given ODR request according to the serving
|
||||||
|
|
|
||||||
|
|
@ -102,35 +102,20 @@ var requests = map[uint64]requestInfo{
|
||||||
type errCode int
|
type errCode int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// ErrMsgTooLarge - message too large
|
|
||||||
ErrMsgTooLarge = iota
|
ErrMsgTooLarge = iota
|
||||||
// ErrDecode - decode error
|
|
||||||
ErrDecode
|
ErrDecode
|
||||||
// ErrInvalidMsgCode - invalid message error
|
|
||||||
ErrInvalidMsgCode
|
ErrInvalidMsgCode
|
||||||
// ErrProtocolVersionMismatch - mismatched protocol version
|
|
||||||
ErrProtocolVersionMismatch
|
ErrProtocolVersionMismatch
|
||||||
// ErrNetworkIDMismatch - wrong network id
|
|
||||||
ErrNetworkIDMismatch
|
ErrNetworkIDMismatch
|
||||||
// ErrGenesisBlockMismatch - incompatible genesis blocks
|
|
||||||
ErrGenesisBlockMismatch
|
ErrGenesisBlockMismatch
|
||||||
// ErrNoStatusMsg -
|
|
||||||
ErrNoStatusMsg
|
ErrNoStatusMsg
|
||||||
// ErrExtraStatusMsg -
|
|
||||||
ErrExtraStatusMsg
|
ErrExtraStatusMsg
|
||||||
// ErrSuspendedPeer -
|
|
||||||
ErrSuspendedPeer
|
ErrSuspendedPeer
|
||||||
// ErrUselessPeer -
|
|
||||||
ErrUselessPeer
|
ErrUselessPeer
|
||||||
// ErrRequestRejected -
|
|
||||||
ErrRequestRejected
|
ErrRequestRejected
|
||||||
// ErrUnexpectedResponse -
|
|
||||||
ErrUnexpectedResponse
|
ErrUnexpectedResponse
|
||||||
// ErrInvalidResponse -
|
|
||||||
ErrInvalidResponse
|
ErrInvalidResponse
|
||||||
// ErrTooManyTimeouts -
|
|
||||||
ErrTooManyTimeouts
|
ErrTooManyTimeouts
|
||||||
// ErrMissingKey -
|
|
||||||
ErrMissingKey
|
ErrMissingKey
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ import (
|
||||||
|
|
||||||
const bufLimitRatio = 6000 // fixed bufLimit/MRR ratio
|
const bufLimitRatio = 6000 // fixed bufLimit/MRR ratio
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
const (
|
const (
|
||||||
logFileName = "" // csv log file name (disabled if empty)
|
logFileName = "" // csv log file name (disabled if empty)
|
||||||
logClientPoolMetrics = true // log client pool metrics
|
logClientPoolMetrics = true // log client pool metrics
|
||||||
|
|
@ -48,6 +49,9 @@ const (
|
||||||
logProtocolHandler = true // log protocol handler events
|
logProtocolHandler = true // log protocol handler events
|
||||||
)
|
)
|
||||||
|
|
||||||
|
=======
|
||||||
|
// LesServer is a node service running a LES server
|
||||||
|
>>>>>>> Correcting documentation format
|
||||||
type LesServer struct {
|
type LesServer struct {
|
||||||
lesCommons
|
lesCommons
|
||||||
|
|
||||||
|
|
@ -70,7 +74,7 @@ type LesServer struct {
|
||||||
priorityClientPool *priorityClientPool
|
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) {
|
func NewLesServer(eth *eth.Ethereum, config *eth.Config) (*LesServer, error) {
|
||||||
var csvLogger *csvlogger.Logger
|
var csvLogger *csvlogger.Logger
|
||||||
if logFileName != "" {
|
if logFileName != "" {
|
||||||
|
|
@ -160,7 +164,7 @@ func NewLesServer(eth *eth.Ethereum, config *eth.Config) (*LesServer, error) {
|
||||||
return srv, nil
|
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 {
|
func (s *LesServer) APIs() []rpc.API {
|
||||||
return []rpc.API{
|
return []rpc.API{
|
||||||
{
|
{
|
||||||
|
|
@ -232,7 +236,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 {
|
func (s *LesServer) Protocols() []p2p.Protocol {
|
||||||
return s.makeProtocols(ServerProtocolVersions)
|
return s.makeProtocols(ServerProtocolVersions)
|
||||||
}
|
}
|
||||||
|
|
@ -291,7 +295,7 @@ func (s *LesServer) Start(srvr *p2p.Server) error {
|
||||||
return nil
|
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) {
|
func (s *LesServer) SetBloomBitsIndexer(bloomIndexer *core.ChainIndexer) {
|
||||||
bloomIndexer.AddChildIndexer(s.bloomTrieIndexer)
|
bloomIndexer.AddChildIndexer(s.bloomTrieIndexer)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue