sync

package
v0.0.0-...-c85edb6 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2019 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package sync defines the utilities for the beacon-chain to sync with the network.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ChainService     chainService
	BeaconDB         *db.BeaconDB
	P2P              p2pAPI
	OperationService operationService
}

Config defines the configured services required for sync to work.

type Querier

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

Querier defines the main class in this package. See the package comments for a general description of the service's functions.

func NewQuerierService

func NewQuerierService(ctx context.Context,
	cfg *QuerierConfig,
) *Querier

NewQuerierService constructs a new Sync Querier Service. This method is normally called by the main node.

func (*Querier) IsSynced

func (q *Querier) IsSynced() (bool, error)

IsSynced checks if the node is cuurently synced with the rest of the network.

func (*Querier) RequestLatestHead

func (q *Querier) RequestLatestHead()

RequestLatestHead broadcasts out a request for all the latest chain heads from the node's peers.

func (*Querier) Start

func (q *Querier) Start()

Start begins the goroutine.

func (*Querier) Stop

func (q *Querier) Stop() error

Stop kills the sync querier goroutine.

type QuerierConfig

type QuerierConfig struct {
	ResponseBufferSize int
	P2P                p2pAPI
	BeaconDB           *db.BeaconDB
}

QuerierConfig defines the configurable properties of SyncQuerier.

func DefaultQuerierConfig

func DefaultQuerierConfig() *QuerierConfig

DefaultQuerierConfig provides the default configuration for a sync service. ResponseBufferSize determines that buffer size of the `responseBuf` channel.

type RegularSync

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

RegularSync is the gateway and the bridge between the p2p network and the local beacon chain. In broad terms, a new block is synced in 4 steps:

  1. Receive a block hash from a peer

  2. Request the block for the hash from the network

  3. Receive the block

  4. Forward block to the beacon service for full validation

    In addition, RegularSync will handle the following responsibilities: * Decide which messages are forwarded to other peers * Filter redundant data and unwanted data * Drop peers that send invalid data * Throttle incoming requests

func NewRegularSyncService

func NewRegularSyncService(ctx context.Context, cfg *RegularSyncConfig) *RegularSync

NewRegularSyncService accepts a context and returns a new Service.

func (*RegularSync) BlockAnnouncementFeed

func (rs *RegularSync) BlockAnnouncementFeed() *event.Feed

BlockAnnouncementFeed returns an event feed processes can subscribe to for newly received, incoming p2p blocks.

func (*RegularSync) ResumeSync

func (rs *RegularSync) ResumeSync()

ResumeSync resumes normal sync after initial sync is complete.

func (*RegularSync) Start

func (rs *RegularSync) Start()

Start begins the block processing goroutine.

func (*RegularSync) Stop

func (rs *RegularSync) Stop() error

Stop kills the block processing goroutine, but does not wait until the goroutine exits.

type RegularSyncConfig

type RegularSyncConfig struct {
	BlockAnnounceBufferSize int
	BlockBufferSize         int
	BlockReqSlotBufferSize  int
	BlockReqHashBufferSize  int
	BatchedBufferSize       int
	AttestationBufferSize   int
	ExitBufferSize          int
	ChainHeadReqBufferSize  int
	ChainService            chainService
	OperationService        operationService
	BeaconDB                *db.BeaconDB
	P2P                     p2pAPI
}

RegularSyncConfig allows the channel's buffer sizes to be changed.

func DefaultRegularSyncConfig

func DefaultRegularSyncConfig() *RegularSyncConfig

DefaultRegularSyncConfig provides the default configuration for a sync service.

type Service

type Service struct {
	RegularSync *RegularSync
	InitialSync *initialsync.InitialSync
	Querier     *Querier
}

Service defines the main routines used in the sync service.

func NewSyncService

func NewSyncService(ctx context.Context, cfg *Config) *Service

NewSyncService creates a new instance of SyncService using the config given.

func (*Service) Start

func (ss *Service) Start()

Start kicks off the sync service

func (*Service) Status

func (ss *Service) Status() error

Status always returns nil. TODO(1206): Add service health checks.

func (*Service) Stop

func (ss *Service) Stop() error

Stop ends all the currently running routines which are part of the sync service.

Directories

Path Synopsis
Package initialsync is run by the beacon node when the local chain is behind the network's longest chain.
Package initialsync is run by the beacon node when the local chain is behind the network's longest chain.

Jump to

Keyboard shortcuts

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