sync2

package
v1.7.9 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDispatcher added in v1.7.9

func NewDispatcher(logger *zap.Logger, host host.Host, opts []server.Opt) *rangesync.Dispatcher

Types

type ATXHandler added in v1.7.9

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

func NewATXHandler added in v1.7.9

func NewATXHandler(
	logger *zap.Logger,
	f Fetcher,
	cfg Config,
	clock clockwork.Clock,
) *ATXHandler

func (*ATXHandler) Commit added in v1.7.9

func (h *ATXHandler) Commit(
	ctx context.Context,
	peer p2p.Peer,
	base rangesync.OrderedSet,
	received rangesync.SeqResult,
) error

type ATXSyncSource added in v1.7.9

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

func NewATXSyncSource added in v1.7.9

func NewATXSyncSource(
	logger *zap.Logger,
	d *rangesync.Dispatcher,
	db sql.Database,
	f Fetcher,
	peers *peers.Peers,
	enableActiveSync bool,
) *ATXSyncSource

func (*ATXSyncSource) CreateHashSync added in v1.7.9

func (as *ATXSyncSource) CreateHashSync(name string, cfg Config, epoch types.EpochID) (HashSync, error)

CreateHashSync implements HashSyncSource.

type Config

type Config struct {
	rangesync.RangeSetReconcilerConfig  `mapstructure:",squash"`
	multipeer.MultiPeerReconcilerConfig `mapstructure:",squash"`
	TrafficLimit                        int           `mapstructure:"traffic-limit"`
	MessageLimit                        int           `mapstructure:"message-limit"`
	MaxDepth                            uint          `mapstructure:"max-depth"`
	BatchSize                           uint          `mapstructure:"batch-size"`
	MaxAttempts                         uint          `mapstructure:"max-attempts"`
	MaxBatchRetries                     uint          `mapstructure:"max-batch-retries"`
	FailedBatchDelay                    time.Duration `mapstructure:"failed-batch-delay"`
}

Config contains the configuration for the P2PHashSync.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default configuration for the P2PHashSync.

func (*Config) Validate added in v1.7.9

func (cfg *Config) Validate(logger *zap.Logger) bool

type Fetcher added in v1.7.9

type Fetcher interface {
	GetAtxs(context.Context, []types.ATXID, ...system.GetAtxOpt) error
	RegisterPeerHashes(peer p2p.Peer, hash []types.Hash32)
}

type HashSync added in v1.7.9

type HashSync interface {
	Load() error
	Start()
	Stop()
	StartAndSync(ctx context.Context) error
}

type HashSyncSource added in v1.7.9

type HashSyncSource interface {
	CreateHashSync(name string, cfg Config, epoch types.EpochID) (HashSync, error)
}

type LayerTicker added in v1.7.9

type LayerTicker interface {
	CurrentLayer() types.LayerID
}

type MultiEpochATXSyncer added in v1.7.9

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

func NewMultiEpochATXSyncer added in v1.7.9

func NewMultiEpochATXSyncer(
	logger *zap.Logger,
	hss HashSyncSource,
	oldCfg, newCfg Config,
	parallelLoadLimit int,
) (*MultiEpochATXSyncer, error)

func (*MultiEpochATXSyncer) EnsureSync added in v1.7.9

func (s *MultiEpochATXSyncer) EnsureSync(
	ctx context.Context,
	lastWaitEpoch, newEpoch types.EpochID,
) (lastSynced types.EpochID, err error)

EnsureSync ensures that ATX sync is active for all the epochs up to and including currentEpoch, and that all ATXs are synced up to and including lastWaitEpoch. If newEpoch argument is non-zero, faster but less memory efficient sync is used for that epoch, based on the newCfg (larger maxDepth). For other epochs, oldCfg is used which corresponds to slower but more memory efficient sync (smaller maxDepth). It returns the last epoch that was synced synchronously.

func (*MultiEpochATXSyncer) Stop added in v1.7.9

func (s *MultiEpochATXSyncer) Stop()

Stop stops all ATX syncers.

type P2PHashSync

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

P2PHashSync is handles the synchronization of a local OrderedSet against other peers.

func NewATXSyncer added in v1.7.9

func NewATXSyncer(
	logger *zap.Logger,
	d *rangesync.Dispatcher,
	name string,
	cfg Config,
	db sql.Database,
	f Fetcher,
	peers *peers.Peers,
	epoch types.EpochID,
	enableActiveSync bool,
) (*P2PHashSync, error)

func NewP2PHashSync

func NewP2PHashSync(
	logger *zap.Logger,
	d *rangesync.Dispatcher,
	name string,
	os rangesync.OrderedSet,
	keyLen int,
	peers *peers.Peers,
	handler multipeer.SyncKeyHandler,
	cfg Config,
	enableActiveSync bool,
) (*P2PHashSync, error)

NewP2PHashSync creates a new P2PHashSync.

func (*P2PHashSync) Load

func (s *P2PHashSync) Load() error

Load loads the OrderedSet from the underlying storage.

func (*P2PHashSync) Set

func (s *P2PHashSync) Set() rangesync.OrderedSet

Set returns the OrderedSet that is being synchronized.

func (*P2PHashSync) Start

func (s *P2PHashSync) Start()

Start starts the multi-peer reconciler if it is not already running.

func (*P2PHashSync) StartAndSync added in v1.7.9

func (s *P2PHashSync) StartAndSync(ctx context.Context) error

StartAndSync starts the multi-peer reconciler if it is not already running, and waits until the local OrderedSet is in sync with the peers.

func (*P2PHashSync) Stop

func (s *P2PHashSync) Stop()

Stop stops the multi-peer reconciler.

func (*P2PHashSync) Synced

func (s *P2PHashSync) Synced() bool

Synced returns true if the local OrderedSet is in sync with the peers, as determined by the multi-peer reconciler.

func (*P2PHashSync) WaitForSync

func (s *P2PHashSync) WaitForSync(ctx context.Context) error

WaitForSync waits until the local OrderedSet is in sync with the peers.

Directories

Path Synopsis
Package rangesync implements pairwise set reconciliation protocol.
Package rangesync implements pairwise set reconciliation protocol.
mocks
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