sync

package
v1.0.0-alpha.22 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2020 License: GPL-3.0 Imports: 64 Imported by: 53

Documentation

Overview

Package sync TODO(3147): Add details on how sync works.

Package sync includes all chain-synchronization logic for the beacon node, including gossip-sub validators for blocks, attestations, and other p2p messages, as well as ability to process and respond to block requests by peers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadChunkedBlock

func ReadChunkedBlock(stream libp2pcore.Stream, p2p p2p.P2P, isFirstChunk bool) (*eth.SignedBeaconBlock, error)

ReadChunkedBlock handles each response chunk that is sent by the peer and converts it into a beacon block.

func ReadStatusCode

func ReadStatusCode(stream network.Stream, encoding encoder.NetworkEncoding) (uint8, string, error)

ReadStatusCode response from a RPC stream.

func SetRPCStreamDeadlines added in v1.0.0

func SetRPCStreamDeadlines(stream network.Stream)

SetRPCStreamDeadlines sets read and write deadlines for libp2p-based connection streams.

func SetStreamReadDeadline added in v1.0.0

func SetStreamReadDeadline(stream network.Stream, duration time.Duration)

SetStreamReadDeadline for reading from libp2p connection streams, deciding when to close a connection based on a particular duration.

NOTE: libp2p uses the system clock time for determining the deadline so we use time.Now() instead of the synchronized roughtime.Now(). If the system time is corrupted (i.e. time does not advance), the node will experience issues being able to properly close streams, leading to unexpected failures and possible memory leaks.

func SetStreamWriteDeadline added in v1.0.0

func SetStreamWriteDeadline(stream network.Stream, duration time.Duration)

SetStreamWriteDeadline for writing to libp2p connection streams, deciding when to close a connection based on a particular duration.

NOTE: libp2p uses the system clock time for determining the deadline so we use time.Now() instead of the synchronized roughtime.Now(). If the system time is corrupted (i.e. time does not advance), the node will experience issues being able to properly close streams, leading to unexpected failures and possible memory leaks.

func WriteChunk

func WriteChunk(stream libp2pcore.Stream, encoding encoder.NetworkEncoding, msg interface{}) error

WriteChunk object to stream. response_chunk ::= | <result> | <encoding-dependent-header> | <encoded-payload>

Types

type Checker

type Checker interface {
	Syncing() bool
	Status() error
	Resync() error
}

Checker defines a struct which can verify whether a node is currently synchronizing a chain with the rest of peers in the network.

type Config

type Config struct {
	P2P                 p2p.P2P
	DB                  db.NoHeadAccessDatabase
	AttPool             attestations.Pool
	ExitPool            *voluntaryexits.Pool
	SlashingPool        *slashings.Pool
	Chain               blockchainService
	InitialSync         Checker
	StateNotifier       statefeed.Notifier
	BlockNotifier       blockfeed.Notifier
	AttestationNotifier operation.Notifier
	StateSummaryCache   *cache.StateSummaryCache
	StateGen            *stategen.State
}

Config to set up the regular sync service.

type Service added in v0.3.0

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

Service is responsible for handling all run time p2p related operations as the main entry point for network messages.

func NewRegularSync

func NewRegularSync(cfg *Config) *Service

NewRegularSync service.

func (*Service) Start added in v0.3.0

func (s *Service) Start()

Start the regular sync service.

func (*Service) Status added in v0.3.0

func (s *Service) Status() error

Status of the currently running regular sync service.

func (*Service) Stop added in v0.3.0

func (s *Service) Stop() error

Stop the regular sync service.

Directories

Path Synopsis
Package initialsync includes all initial block download and processing logic for the beacon node, using a round robin strategy and a finite-state-machine to handle edge-cases in a beacon node's sync status.
Package initialsync includes all initial block download and processing logic for the beacon node, using a round robin strategy and a finite-state-machine to handle edge-cases in a beacon node's sync status.
testing
Package testing includes useful mocks for testing initial sync status in unit tests.
Package testing includes useful mocks for testing initial sync status in unit tests.

Jump to

Keyboard shortcuts

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