sync

package
v0.1.20-ntpfix Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	LayersPerEpoch  uint16
	Concurrency     int // number of workers for sync method
	LayerSize       int
	RequestTimeout  time.Duration
	SyncInterval    time.Duration
	ValidationDelta time.Duration
	AtxsLimit       int
	Hdist           int
	AlwaysListen    bool
}

Configuration represents all config params needed by syncer

type Syncer

type Syncer struct {
	log.Log
	Configuration
	*mesh.Mesh
	// contains filtered or unexported fields
}

Syncer is used to sync the node with the network periodically the Syncer will check if the node is synced with the rest of the network and will follow the sync protocol in order to fetch all missing data and become synced again

func NewSync

func NewSync(srv service.Service, layers *mesh.Mesh, txpool txMemPool, atxDB atxDB, bv blockEligibilityValidator, poetdb poetDb, conf Configuration, clock ticker, logger log.Log) *Syncer

NewSync fires a sync every sm.SyncInterval or on force space from outside

func NewSyncWithMocks added in v0.1.11

func NewSyncWithMocks(atxdbStore *database.LDBDatabase, mshdb *mesh.DB, txpool *state.TxMempool, atxpool *activation.AtxMemDB, swarm service.Service, poetDb *activation.PoetDb, conf Configuration, expectedLayers types.LayerID) *Syncer

NewSyncWithMocks returns a syncer instance that is backed by mocks of other modules for use in testing

func (*Syncer) Await

func (s *Syncer) Await() chan struct{}

Await returns a channel that blocks until the node is synced

func (*Syncer) Close

func (s *Syncer) Close()

Close closes all running goroutines

func (*Syncer) FetchAtx added in v0.1.16

func (s *Syncer) FetchAtx(ID types.ATXID) error

FetchAtx fetches an ATX from remote peer

func (*Syncer) FetchAtxReferences added in v0.1.15

func (s *Syncer) FetchAtxReferences(atx *types.ActivationTx) error

FetchAtxReferences fetches positioning and prev atxs from peers if they are not found in db

func (*Syncer) FetchBlock added in v0.1.16

func (s *Syncer) FetchBlock(ID types.BlockID) error

FetchBlock fetches a single block from peers

func (*Syncer) FetchPoetProof

func (s *Syncer) FetchPoetProof(poetProofRef []byte) error

FetchPoetProof fetches a poet proof from network peers

func (*Syncer) ForceSync

func (s *Syncer) ForceSync()

ForceSync signals syncer to run the synchronise flow

func (*Syncer) GetAtxs added in v0.1.16

func (s *Syncer) GetAtxs(IDs []types.ATXID) error

GetAtxs fetches list of atxs from remote peers if possible

func (*Syncer) GetBlocks added in v0.1.16

func (s *Syncer) GetBlocks(blockIds []types.BlockID) error

GetBlocks fetches list of blocks from peers

func (Syncer) GetExit

func (ms Syncer) GetExit() chan struct{}

func (*Syncer) GetPoetProof added in v0.1.16

func (s *Syncer) GetPoetProof(hash types.Hash32) error

GetPoetProof fetches a poet proof from network peers

func (Syncer) GetTimeout

func (ms Syncer) GetTimeout() time.Duration

func (*Syncer) GetTxs added in v0.1.16

func (s *Syncer) GetTxs(IDs []types.TransactionID) error

GetTxs fetches txs from peers if necessary

func (*Syncer) IsSynced

func (s *Syncer) IsSynced() bool

IsSynced returns true if the node is synced false otherwise

func (*Syncer) ListenToGossip

func (s *Syncer) ListenToGossip() bool

ListenToGossip enables other modules to check if they should listen to gossip

func (*Syncer) Start

func (s *Syncer) Start()

Start starts the main pooling routine that checks the sync status every set interval and calls synchronise if the node is out of sync

Jump to

Keyboard shortcuts

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