syncer

package
v1.5.7 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 24 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")
)
View Source
var (
	MalPeerError = peerError.WithLabelValues("mal")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Interval         time.Duration `mapstructure:"interval"`
	EpochEndFraction float64       `mapstructure:"epochendfraction"`
	HareDelayLayers  uint32
	SyncCertDistance uint32
	// TallyVotesFrequency how often to tally votes during layers sync.
	// Setting this to 0.25 will tally votes after downloading data for quarter of the epoch.
	TallyVotesFrequency      float64
	MaxStaleDuration         time.Duration `mapstructure:"maxstaleduration"`
	Standalone               bool
	GossipDuration           time.Duration  `mapstructure:"gossipduration"`
	DisableMeshAgreement     bool           `mapstructure:"disable-mesh-agreement"`
	OutOfSyncThresholdLayers uint32         `mapstructure:"out-of-sync-threshold"`
	AtxSync                  atxsync.Config `mapstructure:"atx-sync"`
	MalSync                  malsync.Config `mapstructure:"malfeasance-sync"`
}

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,
	tortoise system.Tortoise,
	lg log.Log,
) *DataFetch

NewDataFetch creates a new DataFetch instance.

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)

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,
	tortoise system.Tortoise,
	fetcher fetcher,
	patrol layerPatrol,
	ch certHandler,
	atxSyncer atxSyncer,
	malSyncer malSyncer,
	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
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package blockssync is a generated GoMock package.
Package blockssync is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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