malsync

package
v1.7.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// IDRequestInterval specifies the interval for malfeasance proof id requests to the network.
	IDRequestInterval time.Duration `mapstructure:"id-request-interval"`

	// MalfeasanceIDPeers is the number of peers to fetch node IDs for malfeasance proofs from.
	MalfeasanceIDPeers int `mapstructure:"malfeasance-id-peers"`

	// Minimum number of peers to sync against for initial sync to be considered complete.
	MinSyncPeers int `mapstructure:"min-sync-peers"`

	// MaxEpochFraction specifies maximum fraction of epoch to expire before
	// synchronous malfeasance proof sync is needed upon startup.
	MaxEpochFraction float64 `mapstructure:"max-epoch-fraction"`

	// MaxBatchSize is the maximum number of node IDs to sync in a single request.
	MaxBatchSize int `mapstructure:"max-batch-size"`

	// RequestsLimit is the maximum number of requests for a single malfeasance proof.
	//
	// The purpose of it is to prevent peers from advertising invalid node ID and disappearing.
	// Which will make node ask other peers for invalid malfeasance proofs.
	// It will be reset to 0 once malfeasance proof is advertised again.
	RequestsLimit int `mapstructure:"requests-limit"`

	// RetryInterval specifies retry interval for the initial sync.
	RetryInterval time.Duration `mapstructure:"retry-interval"`
}

func DefaultConfig

func DefaultConfig() Config

type Opt

type Opt func(*Syncer)

func WithConfig

func WithConfig(cfg Config) Opt

func WithLogger

func WithLogger(logger *zap.Logger) Opt

func WithPeerErrMetric

func WithPeerErrMetric(counter counter) Opt

type Syncer

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

func New

func New(fetcher fetcher, db sql.Executor, localdb sql.LocalDatabase, opts ...Opt) *Syncer

func (*Syncer) DownloadLoop

func (s *Syncer) DownloadLoop(parent context.Context) error

func (*Syncer) EnsureInSync

func (s *Syncer) EnsureInSync(parent context.Context, epochStart, epochEnd time.Time) error

Directories

Path Synopsis
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