Documentation ¶
Overview ¶
Package layerfetcher fetches layers from remote peers
Index ¶
- Variables
- type Config
- type DataHandlers
- type Future
- type LayerPromiseResult
- type Logic
- func (l *Logic) Close()
- func (l *Logic) FetchAtx(ctx context.Context, id types.ATXID) error
- func (l *Logic) GetAtxs(ctx context.Context, IDs []types.ATXID) error
- func (l *Logic) GetBallots(ctx context.Context, ids []types.BallotID) error
- func (l *Logic) GetBlocks(ctx context.Context, ids []types.BlockID) error
- func (l *Logic) GetEpochATXs(ctx context.Context, id types.EpochID) error
- func (l *Logic) GetPoetProof(ctx context.Context, id types.Hash32) error
- func (l *Logic) GetProposals(ctx context.Context, ids []types.ProposalID) error
- func (l *Logic) GetTxs(ctx context.Context, IDs []types.TransactionID) error
- func (l *Logic) PollLayerContent(ctx context.Context, layerID types.LayerID) chan LayerPromiseResult
- func (l *Logic) Start()
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoPeers is returned when node has no peers. ErrNoPeers = errors.New("no peers") // ErrInternal is returned from the peer when the peer encounters an internal error. ErrInternal = errors.New("unspecified error returned by peer") // ErrLayerDataNotFetched is returned when any layer data is not fetched successfully. ErrLayerDataNotFetched = errors.New("layer data not fetched") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config defines configuration for layer fetching logic.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns default configuration for layer fetching logic.
type DataHandlers ¶
type DataHandlers struct { ATX atxHandler Ballot ballotHandler Block blockHandler Proposal proposalHandler TX txHandler }
DataHandlers collects handlers for different data type.
type Future ¶
type Future struct {
// contains filtered or unexported fields
}
Future is a preparation for using actual futures in the code, this will allow to truly execute asynchronous reads and receive result only when needed.
func (*Future) Result ¶
func (f *Future) Result() fetch.HashDataPromiseResult
Result actually evaluates the result of the fetch task.
type LayerPromiseResult ¶
LayerPromiseResult is the result of trying to fetch data for an entire layer.
type Logic ¶
type Logic struct {
// contains filtered or unexported fields
}
Logic is the struct containing components needed to follow layer fetching logic.
func NewLogic ¶
func NewLogic(ctx context.Context, cfg Config, poet poetDB, atxIDs atxIDsDB, layers layerDB, host *p2p.Host, handlers DataHandlers, dbStores fetch.LocalDataSource, log log.Log, ) *Logic
NewLogic creates a new instance of layer fetching logic.
func (*Logic) GetAtxs ¶
GetAtxs gets the data for given atx ids IDs and validates them. returns an error if at least one ATX cannot be fetched.
func (*Logic) GetBallots ¶
GetBallots gets data for the specified BallotIDs and validates them.
func (*Logic) GetEpochATXs ¶
GetEpochATXs fetches all atxs received by peer for given layer.
func (*Logic) GetPoetProof ¶
GetPoetProof gets poet proof from remote peer.
func (*Logic) GetProposals ¶
GetProposals gets the data for given proposal IDs from peers.
func (*Logic) GetTxs ¶
GetTxs fetches the txs provided as IDs and validates them, returns an error if one TX failed to be fetched.
func (*Logic) PollLayerContent ¶
func (l *Logic) PollLayerContent(ctx context.Context, layerID types.LayerID) chan LayerPromiseResult
PollLayerContent polls peers for the content of a given layer ID. it returns a channel for the caller to be notified when responses are received from all peers.