layerfetcher

package
v0.2.0-rc7 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package layerfetcher fetches layers from remote peers

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPeers = errors.New("no peers")

ErrNoPeers is returned when node has no peers.

View Source
var ErrTooManyPeerErrors = errors.New("too many peers returned error")

ErrTooManyPeerErrors is returned when too many (> 1/2) peers return error

View Source
var ErrZeroLayer = errors.New("zero layer")

ErrZeroLayer is the error returned when an empty hash is received when polling for layer

Functions

This section is empty.

Types

type Config

type Config struct {
	RequestTimeout int
	GoldenATXID    types.ATXID
}

Config defines configuration for layer fetching logic

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns default configuration for layer fetching logic

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 LayerHashResult

type LayerHashResult struct {
	Hashes map[layerHash][]peers.Peer
	Err    error
}

LayerHashResult is the result of fetching hashes for each layer from peers.

type LayerPromiseResult

type LayerPromiseResult struct {
	Err   error
	Layer types.LayerID
}

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, blocks blockHandler, atxs atxHandler, poet poetDB, atxIDs atxIDsDB, txs TxProcessor, network service.Service, fetcher fetch.Fetcher, layers layerDB, tortoiseBeacons tortoiseBeaconDB, log log.Log) *Logic

NewLogic creates a new instance of layer fetching logic

func (*Logic) AddDBs

func (l *Logic) AddDBs(blockDB, AtxDB, TxDB, poetDB, IvDB, tbDB database.Getter)

AddDBs adds dbs that will be queried when sync requests are received. these databases will be exposed to external callers

func (*Logic) Close

func (l *Logic) Close()

Close closes all running workers

func (*Logic) FetchAtx

func (l *Logic) FetchAtx(ctx context.Context, id types.ATXID) error

FetchAtx returns error if ATX was not found

func (*Logic) FetchBlock

func (l *Logic) FetchBlock(ctx context.Context, id types.BlockID) error

FetchBlock gets data for a single block id and validates it

func (*Logic) GetAtxs

func (l *Logic) GetAtxs(ctx context.Context, IDs []types.ATXID) error

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

func (l *Logic) GetBlocks(ctx context.Context, IDs []types.BlockID) error

GetBlocks gets the data for given block ids and validates the blocks. returns an error if a single atx failed to be fetched or validated

func (*Logic) GetEpochATXs

func (l *Logic) GetEpochATXs(ctx context.Context, id types.EpochID) error

GetEpochATXs fetches all atxs received by peer for given layer

func (*Logic) GetInputVector

func (l *Logic) GetInputVector(ctx context.Context, id types.LayerID) error

GetInputVector gets input vector data from remote peer

func (*Logic) GetPoetProof

func (l *Logic) GetPoetProof(ctx context.Context, id types.Hash32) error

GetPoetProof gets poet proof from remote peer

func (*Logic) GetTortoiseBeacon

func (l *Logic) GetTortoiseBeacon(ctx context.Context, id types.EpochID) error

GetTortoiseBeacon gets tortoise beacon data from remote peer

func (*Logic) GetTxs

func (l *Logic) GetTxs(ctx context.Context, IDs []types.TransactionID) error

GetTxs fetches the txs provided as IDs and validates them, returns an error if one TX failed to be fetched

func (*Logic) IsSynced

func (l *Logic) IsSynced(context.Context) bool

IsSynced indicates if this node is synced

func (*Logic) ListenToGossip

func (l *Logic) ListenToGossip() bool

ListenToGossip indicates if node is currently accepting packets from gossip

func (*Logic) PollLayerBlocks

func (l *Logic) PollLayerBlocks(ctx context.Context, layerID types.LayerID, hashes map[types.Hash32][]peers.Peer) chan LayerPromiseResult

PollLayerBlocks polls peers on blocks for given layer hashes. for each layer hash, it requests the blocks from a peer that reported the layer hash previously. it returns a channel for the caller to be notified when responses are received from all peers.

func (*Logic) PollLayerHash

func (l *Logic) PollLayerHash(ctx context.Context, layerID types.LayerID) chan LayerHashResult

PollLayerHash polls peers on the layer hash. it returns a channel for the caller to be notified when responses are received from all peers.

func (*Logic) Start

func (l *Logic) Start()

Start starts layerFetcher logic and fetch component

type TxProcessor

type TxProcessor interface {
	HandleTxSyncData(data []byte) error
}

TxProcessor is an interface for handling TX data received in sync

Jump to

Keyboard shortcuts

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