les

package
v2.1.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2022 License: GPL-3.0 Imports: 65 Imported by: 2

Documentation

Overview

Package les implements the Light Truechain 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
	MaxSnailBodyFetch        = 128 // Amount of block bodies to be fetched per retrieval request
	MaxFruitBodyFetch        = 128 // 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 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
	MsgSnailBlockBodies
	MsgFruitBodies
	MsgCode
	MsgReceipts
	MsgProofsV2
	MsgHelperTrieProofs
	MsgTxStatus
)
View Source
const (
	NetworkId          = 1
	ProtocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message
)
View Source
const (
	// Protocol messages inherited from LPV1
	StatusMsg               = 0x00
	AnnounceMsg             = 0x01
	GetFastBlockHeadersMsg  = 0x02
	FastBlockHeadersMsg     = 0x03
	GetFastBlockBodiesMsg   = 0x04
	FastBlockBodiesMsg      = 0x05
	GetSnailBlockHeadersMsg = 0x06
	SnailBlockHeadersMsg    = 0x07
	GetSnailBlockBodiesMsg  = 0x08
	SnailBlockBodiesMsg     = 0x09
	GetFruitBodiesMsg       = 0x0a
	FruitBodiesMsg          = 0x0b

	GetReceiptsMsg = 0x0c
	ReceiptsMsg    = 0x0d
	// Protocol messages belonging to LPV2
	GetCodeMsg             = 0x0e
	CodeMsg                = 0x0f
	GetProofsV2Msg         = 0x10
	ProofsV2Msg            = 0x11
	GetHelperTrieProofsMsg = 0x12
	HelperTrieProofsMsg    = 0x13
	SendTxV2Msg            = 0x15
	GetTxStatusMsg         = 0x16
	TxStatusMsg            = 0x17
	// Protocol messages introduced in LPV3
	StopMsg   = 0x18
	ResumeMsg = 0x19
)

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 (
	ErrCommittee     = errors.New("get committee failed")
	ErrInvalidMember = errors.New("invalid committee member")
	ErrInvalidSwitch = errors.New("invalid switch block info")
)
View Source
var (
	ClientProtocolVersions    = []uint{lpv2}
	ServerProtocolVersions    = []uint{lpv2}
	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

func ElectionEpoch

func ElectionEpoch(id *big.Int) (begin *big.Int, end *big.Int)

Types

type BlockBodiesRawData

type BlockBodiesRawData struct {
	Bodies     []rlp.RawValue
	FruitHeads []*fruitHeadsData
	Type       uint32 // Distinguish fetcher and downloader
}

BlockBodiesRawData represents a block header send.

type BlockChain

type BlockChain interface {
	Config() *params.ChainConfig
	HasHeader(hash common.Hash, number uint64) bool
	GetHeader(hash common.Hash, number uint64) *types.SnailHeader
	GetHeaderByHash(hash common.Hash) *types.SnailHeader
	CurrentHeader() *types.SnailHeader
	GetTd(hash common.Hash, number uint64) *big.Int
	InsertHeaderChain(chain []*types.SnailHeader, fruits [][]*types.SnailHeader, checkFreq int) (int, error)
	Rollback(chain []common.Hash)
	GetHeaderByNumber(number uint64) *types.SnailHeader
	GetAncestor(hash common.Hash, number, ancestor uint64, maxNonCanonical *uint64) (common.Hash, uint64)
	Genesis() *types.SnailBlock
	SubscribeChainHeadEvent(ch chan<- types.SnailChainHeadEvent) 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 etruedb.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)

type BloomReq

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

type BloomRequest

type BloomRequest fast.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 etruedb.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)

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 etruedb.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)

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 fast.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 etruedb.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)

type Election

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

func NewLightElection

func NewLightElection(fastBlockChain *fast.LightChain, snailBlockChain *light.LightChain) *Election

NewLightElection create the instance of committee electioin

func (*Election) FinalizeCommittee

func (e *Election) FinalizeCommittee(block *types.Block) error

FinalizeCommittee upddate current committee state

func (*Election) GenerateFakeSigns

func (e *Election) GenerateFakeSigns(fb *types.Block) ([]*types.PbftSign, error)

func (*Election) GetCommittee

func (e *Election) GetCommittee(fastNumber *big.Int) []*types.CommitteeMember

GetCommittee gets committee members which propose the fast block

func (*Election) GetMemberByPubkey

func (e *Election) GetMemberByPubkey(members []*types.CommitteeMember, publickey []byte) *types.CommitteeMember

GetMemberByPubkey returns committeeMember specified by public key bytes

func (*Election) GetMemberFlag

func (e *Election) GetMemberFlag(members []*types.CommitteeMember, publickey []byte) uint32

func (*Election) IsCommitteeMember

func (e *Election) IsCommitteeMember(members []*types.CommitteeMember, publickey []byte) bool

IsCommitteeMember reports whether the provided public key is in committee

func (*Election) Start

func (e *Election) Start()

func (*Election) VerifyPublicKey

func (e *Election) VerifyPublicKey(fastHeight *big.Int, pubKeyByte []byte) (*types.CommitteeMember, error)

VerifyPublicKey get the committee member by public key

func (*Election) VerifySign

func (e *Election) VerifySign(sign *types.PbftSign) (*types.CommitteeMember, error)

VerifySign lookup the pbft sign and return the committee member who signs it

func (*Election) VerifySigns

func (e *Election) VerifySigns(signs []*types.PbftSign) ([]*types.CommitteeMember, []error)

VerifySigns verify signatures of bft committee in batches

func (*Election) VerifySwitchInfo

func (e *Election) VerifySwitchInfo(fastNumber *big.Int, info []*types.CommitteeMember) error

VerifySwitchInfo verify committee members and it's state

type FastBlockChain

type FastBlockChain 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
	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<- types.FastChainHeadEvent) event.Subscription
	SetCommitteeInfo(hash common.Hash, number uint64, infos []*types.CommitteeMember)
}

type FastBlockRequest

type FastBlockRequest fast.BlockRequest

FastBlockRequest is the ODR request type for block bodies

func (*FastBlockRequest) CanSend

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

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

func (*FastBlockRequest) GetCost

func (r *FastBlockRequest) 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 (*FastBlockRequest) Request

func (r *FastBlockRequest) Request(reqID uint64, peer *peer) error

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

func (*FastBlockRequest) Validate

func (r *FastBlockRequest) Validate(db etruedb.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)

type FruitRequest

type FruitRequest light.BlockRequest

BlockRequest is the ODR request type for block bodies

func (*FruitRequest) CanSend

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

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

func (*FruitRequest) GetCost

func (r *FruitRequest) 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 (*FruitRequest) Request

func (r *FruitRequest) Request(reqID uint64, peer *peer) error

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

func (*FruitRequest) Validate

func (r *FruitRequest) Validate(db etruedb.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)

type HelperTrieReq

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

type HelperTrieResps

type HelperTrieResps struct {
	Proofs  public.NodeList
	AuxData [][]byte
	Heads   []*types.SnailHeader
	Fhead   []*types.Header
}

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() etruedb.Database

func (*LesApiBackend) CurrentBlock

func (b *LesApiBackend) CurrentBlock() *types.Block

func (*LesApiBackend) CurrentSnailBlock added in v1.1.2

func (b *LesApiBackend) CurrentSnailBlock() *types.SnailBlock

func (*LesApiBackend) Downloader

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

func (*LesApiBackend) EventMux

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

func (*LesApiBackend) ExtRPCEnabled

func (b *LesApiBackend) ExtRPCEnabled() bool

func (*LesApiBackend) GetBalanceChangeBySnailNumber

func (b *LesApiBackend) GetBalanceChangeBySnailNumber(snailNumber rpc.BlockNumber) *types.BalanceChangeContent

func (*LesApiBackend) GetBlock

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

func (*LesApiBackend) GetChainRewardContent

func (b *LesApiBackend) GetChainRewardContent(blockNr rpc.BlockNumber) *types.ChainReward

func (*LesApiBackend) GetCommittee

func (b *LesApiBackend) GetCommittee(number rpc.BlockNumber) (map[string]interface{}, error)

func (*LesApiBackend) GetCurrentCommitteeNumber

func (b *LesApiBackend) GetCurrentCommitteeNumber() *big.Int

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

func (b *LesApiBackend) GetFruit(ctx context.Context, fastblockHash common.Hash) (*types.SnailBlock, 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) GetReward

func (b *LesApiBackend) GetReward(number int64) *types.BlockReward

func (*LesApiBackend) GetSnailBlock

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

func (*LesApiBackend) GetSnailRewardContent added in v1.0.2

func (b *LesApiBackend) GetSnailRewardContent(number rpc.BlockNumber) *types.SnailRewardContenet

func (*LesApiBackend) GetStateChangeByFastNumber

func (b *LesApiBackend) GetStateChangeByFastNumber(fastNumber rpc.BlockNumber) *types.BlockBalance

func (*LesApiBackend) GetTd

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

func (*LesApiBackend) GetTransaction

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

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)

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)

func (*LesApiBackend) SetHead

func (b *LesApiBackend) SetHead(number uint64)

func (*LesApiBackend) SetSnailHead

func (b *LesApiBackend) SetSnailHead(number uint64)

func (*LesApiBackend) SnailBlockByNumber

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

func (*LesApiBackend) SnailHeaderByNumber

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

func (*LesApiBackend) SnailPoolContent

func (b *LesApiBackend) SnailPoolContent() []*types.SnailBlock

func (*LesApiBackend) SnailPoolInspect

func (b *LesApiBackend) SnailPoolInspect() []*types.SnailBlock

func (*LesApiBackend) SnailPoolStats

func (b *LesApiBackend) SnailPoolStats() (pending int, unVerified int)

func (*LesApiBackend) StateAndHeaderByHash

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

func (*LesApiBackend) StateAndHeaderByNumber

func (b *LesApiBackend) StateAndHeaderByNumber(ctx context.Context, blockNr 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) Stats

func (b *LesApiBackend) Stats() (pending int, queued int)

func (*LesApiBackend) SubscribeChainEvent

func (b *LesApiBackend) SubscribeChainEvent(ch chan<- types.FastChainEvent) event.Subscription

func (*LesApiBackend) SubscribeChainHeadEvent

func (b *LesApiBackend) SubscribeChainHeadEvent(ch chan<- types.FastChainHeadEvent) event.Subscription

func (*LesApiBackend) SubscribeChainSideEvent

func (b *LesApiBackend) SubscribeChainSideEvent(ch chan<- types.FastChainSideEvent) event.Subscription

func (*LesApiBackend) SubscribeLogsEvent

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

func (*LesApiBackend) SubscribeNewTxsEvent

func (b *LesApiBackend) SubscribeNewTxsEvent(ch chan<- types.NewTxsEvent) event.Subscription

func (*LesApiBackend) SubscribeRemovedLogsEvent

func (b *LesApiBackend) SubscribeRemovedLogsEvent(ch chan<- types.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 etruedb.Database, config *public.IndexerConfig, 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() *snailchain.ChainIndexer

ChtIndexer returns the CHT chain indexer

func (*LesOdr) Database

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

Database returns the backing database

func (*LesOdr) FastIndexerConfig

func (odr *LesOdr) FastIndexerConfig() *public.IndexerConfig

FastIndexerConfig returns the indexer config.

func (*LesOdr) FastRetrieve

func (odr *LesOdr) FastRetrieve(ctx context.Context, req fast.OdrRequest) (err error)

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

func (*LesOdr) IndexerConfig

func (odr *LesOdr) IndexerConfig() *public.IndexerConfig

IndexerConfig returns the indexer config.

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.

func (*LesOdr) SetIndexers

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

SetIndexers adds the necessary chain indexers to the 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(etruedb.Database, *Msg) error
}

func LesRequest

func LesRequest(req light.OdrRequest) LesOdrRequest

type LesServer

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

func NewLesServer

func NewLesServer(etrue *etrue.Truechain, config *etrue.Config) (*LesServer, error)

func (*LesServer) APIs

func (s *LesServer) APIs() []rpc.API

func (*LesServer) Protocols

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

func (*LesServer) SetBloomBitsIndexer

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

func (*LesServer) SetContractBackend

func (s *LesServer) SetContractBackend(backend bind.ContractBackend)

SetClient sets the rpc client and starts running checkpoint contract if it is not yet watched.

func (*LesServer) Start

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

Start starts the LES server

func (*LesServer) Stop

func (s *LesServer) Stop()

Stop stops the LES service

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 LightEtrue

type LightEtrue struct {
	ApiBackend *LesApiBackend
	// contains filtered or unexported fields
}

func New

func New(ctx *node.ServiceContext, config *etrue.Config) (*LightEtrue, error)

func (*LightEtrue) APIs

func (s *LightEtrue) 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 (*LightEtrue) BlockChain

func (s *LightEtrue) BlockChain() *fast.LightChain

func (*LightEtrue) Downloader

func (s *LightEtrue) Downloader() *downloader.Downloader

func (*LightEtrue) Engine

func (s *LightEtrue) Engine() consensus.Engine

func (*LightEtrue) EventMux

func (s *LightEtrue) EventMux() *event.TypeMux

func (*LightEtrue) LesVersion

func (s *LightEtrue) LesVersion() int

func (*LightEtrue) Protocols

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

Protocols implements node.Service, returning all the currently configured network protocols to start.

func (*LightEtrue) ResetWithGenesisBlock

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

func (*LightEtrue) SetContractBackend

func (s *LightEtrue) SetContractBackend(backend bind.ContractBackend)

SetClient sets the rpc client and binds the registrar contract.

func (*LightEtrue) SnailBlockChain

func (s *LightEtrue) SnailBlockChain() *light.LightChain

func (*LightEtrue) Start

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

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

func (*LightEtrue) Stop

func (s *LightEtrue) Stop() error

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

func (*LightEtrue) TxPool

func (s *LightEtrue) TxPool() *fast.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)
	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
	Difficulty   *big.Int                 `json:"difficulty"`   // Total difficulty of the host's blockchain
	SnailGenesis common.Hash              `json:"snailGenesis"` // SHA3 hash of the host's genesis block
	SnailConfig  *params.ChainConfig      `json:"snailConfig"`  // Chain configuration for the fork rules
	SnailHead    common.Hash              `json:"snailHead"`    // SHA3 hash of the host's best owned block
}

NodeInfo represents a short summary of the Ethereum sub-protocol metadata known about the host peer.

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, reg *checkpointOracle) *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 ProofReq

type ProofReq struct {
	BHash       common.Hash
	AccKey, Key []byte
	FromLevel   uint
}

type ProtocolManager

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

func NewProtocolManager

func NewProtocolManager(chainConfig *params.ChainConfig, checkpoint *params.TrustedCheckpoint, indexerConfig *public.IndexerConfig, ulcServers []string, ulcFraction int, client bool, networkId uint64, mux *event.TypeMux, engine consensus.Engine, peers *peerSet, blockchain FastBlockChain, snailchain BlockChain, txpool txPool, chainDb etruedb.Database, odr *LesOdr, serverPool *serverPool, registrar *checkpointOracle, quitSync chan struct{}, wg *sync.WaitGroup, election *Election, synced func() bool) (*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)

func (*ProtocolManager) Stop

func (pm *ProtocolManager) Stop()

type ReceiptsRequest

type ReceiptsRequest fast.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 etruedb.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)

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 SyncCallback

type SyncCallback func()

type TrieRequest

type TrieRequest fast.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 etruedb.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)

type TxStatusRequest

type TxStatusRequest fast.TxStatusRequest

TxStatusRequest is the ODR request type for transaction status

func (*TxStatusRequest) CanSend

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

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

func (*TxStatusRequest) GetCost

func (r *TxStatusRequest) 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 (*TxStatusRequest) Request

func (r *TxStatusRequest) Request(reqID uint64, peer *peer) error

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

func (*TxStatusRequest) Validate

func (r *TxStatusRequest) Validate(db etruedb.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)

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