Documentation ¶
Overview ¶
Package messagehandler contains useful helpers for recovering from panic conditions at runtime and logging their trace.
Package sync includes all chain-synchronization logic for the astranet node, including gossip-sub blocks, txs, and other p2p messages, as well as ability to process and respond to block requests by peers.
Index ¶
- Variables
- func ReadChunkedBlock(stream libp2pcore.Stream, p2p p2p.EncodingProvider, isFirstChunk bool) (*types_pb.Block, error)
- func ReadStatusCode(stream network.Stream, encoding encoder.NetworkEncoding) (uint8, string, error)
- func SendBodiesByRangeRequest(ctx context.Context, chain common.IBlockChain, p2pProvider p2p.SenderEncoder, ...) ([]*types_pb.Block, error)
- func SetRPCStreamDeadlines(stream network.Stream)
- func SetStreamReadDeadline(stream network.Stream, duration time.Duration)
- func SetStreamWriteDeadline(stream network.Stream, duration time.Duration)
- func WriteBlockChunk(stream libp2pcore.Stream, chain common.IBlockChain, ...) error
- type BlockProcessor
- type Checker
- type Option
- type Service
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidFetchedData = errors.New("invalid data returned from peer")
ErrInvalidFetchedData is thrown if stream fails to provide requested blocks.
var (
ErrOptimisticParent = errors.New("parent of the block is optimistic")
)
Functions ¶
func ReadChunkedBlock ¶
func ReadChunkedBlock(stream libp2pcore.Stream, p2p p2p.EncodingProvider, isFirstChunk bool) (*types_pb.Block, error)
ReadChunkedBlock handles each response chunk that is sent by the peer and converts it into a beacon block.
func ReadStatusCode ¶
ReadStatusCode response from a RPC stream.
func SendBodiesByRangeRequest ¶
func SendBodiesByRangeRequest(ctx context.Context, chain common.IBlockChain, p2pProvider p2p.SenderEncoder, pid peer.ID, req *sync_pb.BodiesByRangeRequest, blockProcessor BlockProcessor) ([]*types_pb.Block, error)
SendBodiesByRangeRequest sends BeaconBlocksByRange and returns fetched blocks, if any.
func SetRPCStreamDeadlines ¶
SetRPCStreamDeadlines sets read and write deadlines for libp2p-based connection streams.
func SetStreamReadDeadline ¶
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 ¶
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 WriteBlockChunk ¶
func WriteBlockChunk(stream libp2pcore.Stream, chain common.IBlockChain, encoding encoder.NetworkEncoding, blk types.IBlock) error
WriteBlockChunk writes block chunk object to stream. response_chunk ::= <result> | <context-bytes> | <encoding-dependent-header> | <encoded-payload>
Types ¶
type BlockProcessor ¶
BlockProcessor defines a block processing function, which allows to start utilizing blocks even before all blocks are ready.
type Checker ¶
Checker defines a struct which can verify whether a node is currently synchronizing a chain with the rest of peers in the network.
type Option ¶
func WithChainService ¶
func WithChainService(chain common.IBlockChain) Option
func WithInitialSync ¶
type Service ¶
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 NewService ¶
NewService initializes new regular sync service.
Source Files ¶
- context.go
- deadlines.go
- decode_pubsub.go
- error.go
- messagehandler.go
- metrics.go
- options.go
- rate_limiter.go
- rpc.go
- rpc_blocks_by_range.go
- rpc_chunked_response.go
- rpc_goodbye.go
- rpc_ping.go
- rpc_send_request.go
- rpc_status.go
- service.go
- subscriber.go
- subscriber_blocks.go
- subscription_topic_handler.go
- validate_blocks.go
Directories ¶
Path | Synopsis |
---|---|
Package initialsync includes all initial block download and processing logic for the 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 node, using a round robin strategy and a finite-state-machine to handle edge-cases in a beacon node's sync status. |