syncer

package
v1.3.0-increased-cache... Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPeerMeshChangedMidSession = errors.New("peer mesh changed mid session")
	ErrNodeMeshChangedMidSession = errors.New("node mesh changed mid session")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Interval                 time.Duration
	EpochEndFraction         float64
	HareDelayLayers          uint32
	SyncCertDistance         uint32
	MaxStaleDuration         time.Duration
	Standalone               bool
	GossipDuration           time.Duration
	OutOfSyncThresholdLayers uint32 `mapstructure:"out-of-sync-threshold"`
}

Config is the config params for syncer.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig for the syncer.

type DataFetch

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

DataFetch contains the logic of fetching mesh data.

func NewDataFetch

func NewDataFetch(
	msh meshProvider,
	fetch fetcher,
	ids idProvider,
	cache activeSetCache,
	lg log.Log,
) *DataFetch

NewDataFetch creates a new DataFetch instance.

func (*DataFetch) GetEpochATXs

func (d *DataFetch) GetEpochATXs(ctx context.Context, epoch types.EpochID) error

GetEpochATXs fetches all ATXs published in the specified epoch from a peer.

func (*DataFetch) PollLayerData

func (d *DataFetch) PollLayerData(ctx context.Context, lid types.LayerID, peers ...p2p.Peer) error

PollLayerData polls all peers for data in the specified layer.

func (*DataFetch) PollLayerOpinions

func (d *DataFetch) PollLayerOpinions(
	ctx context.Context,
	lid types.LayerID,
	needCert bool,
	peers []p2p.Peer,
) ([]*fetch.LayerOpinion, []*types.Certificate, error)

func (*DataFetch) PollMaliciousProofs

func (d *DataFetch) PollMaliciousProofs(ctx context.Context) error

PollMaliciousProofs polls all peers for malicious NodeIDs.

type ForkFinder

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

func NewForkFinder

func NewForkFinder(lg log.Log, db sql.Executor, f fetcher, maxStale time.Duration) *ForkFinder

func (*ForkFinder) AddResynced

func (ff *ForkFinder) AddResynced(lid types.LayerID, hash types.Hash32)

func (*ForkFinder) FindFork

func (ff *ForkFinder) FindFork(
	ctx context.Context,
	peer p2p.Peer,
	diffLid types.LayerID,
	diffHash types.Hash32,
) (types.LayerID, error)

FindFork finds the point of divergence in layer opinions between the node and the specified peer from a given disagreed layer.

func (*ForkFinder) NeedResync

func (ff *ForkFinder) NeedResync(lid types.LayerID, hash types.Hash32) bool

func (*ForkFinder) NumPeersCached

func (ff *ForkFinder) NumPeersCached() int

NumPeersCached returns the number of peer agreement cached.

func (*ForkFinder) Purge

func (ff *ForkFinder) Purge(all bool, toPurge ...p2p.Peer)

Purge cached agreements with peers.

func (*ForkFinder) UpdateAgreement

func (ff *ForkFinder) UpdateAgreement(
	peer p2p.Peer,
	lid types.LayerID,
	hash types.Hash32,
	created time.Time,
)

UpdateAgreement updates the layer at which the peer agreed with the node.

type Option

type Option func(*Syncer)

Option is a type to configure a syncer.

func WithConfig

func WithConfig(c Config) Option

WithConfig ...

func WithLogger

func WithLogger(l log.Log) Option

WithLogger ...

type Syncer

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

Syncer is responsible to keep the node in sync with the network.

func NewSyncer

func NewSyncer(
	cdb *datastore.CachedDB,
	ticker layerTicker,
	beacon system.BeaconGetter,
	mesh *mesh.Mesh,
	cache activeSetCache,
	fetcher fetcher,
	patrol layerPatrol,
	ch certHandler,
	opts ...Option,
) *Syncer

NewSyncer creates a new Syncer instance.

func (*Syncer) Close

func (s *Syncer) Close()

Close stops the syncing process and the goroutines syncer spawns.

func (*Syncer) IsBeaconSynced

func (s *Syncer) IsBeaconSynced(epoch types.EpochID) bool

func (*Syncer) IsSynced

func (s *Syncer) IsSynced(ctx context.Context) bool

IsSynced returns true if the node is in synced state.

func (*Syncer) ListenToATXGossip

func (s *Syncer) ListenToATXGossip() bool

ListenToATXGossip returns true if the node is listening to gossip for ATXs data.

func (*Syncer) ListenToGossip

func (s *Syncer) ListenToGossip() bool

ListenToGossip returns true if the node is listening to gossip for blocks/TXs data.

func (*Syncer) RegisterForATXSynced

func (s *Syncer) RegisterForATXSynced() <-chan struct{}

RegisterForATXSynced returns a channel for notification when the node enters ATX synced state.

func (*Syncer) Start

func (s *Syncer) Start()

Start starts the main sync loop that tries to sync data for every SyncInterval.

Directories

Path Synopsis
Code generated by MockGen.
Code generated by MockGen.
Code generated by MockGen.
Code generated by MockGen.

Jump to

Keyboard shortcuts

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