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 ¶
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.
type QuerierConfig ¶
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:
Receive a block hash from a peer
Request the block for the hash from the network
Receive the block
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 ¶
NewSyncService creates a new instance of SyncService using the config given.
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. |