Documentation ¶
Overview ¶
Package types implements the network messages for a synchronization.
The messages are implemented in a different package to prevent cycle imports when importing the serde formats.
Documentation Last Review: 13.10.2020
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterMessageFormat ¶
func RegisterMessageFormat(f serde.Format, e serde.FormatEngine)
RegisterMessageFormat registers the engine for the given format.
Types ¶
type MessageFactory ¶
type MessageFactory struct {
// contains filtered or unexported fields
}
MessageFactory is a message factory for sync messages.
- implements serde.Factory
func NewMessageFactory ¶
func NewMessageFactory(fac types.LinkFactory, chainFac types.ChainFactory) MessageFactory
NewMessageFactory createsa new message factory.
func (MessageFactory) Deserialize ¶
Deserialize implements serde.Factory. It returns the message associated to the data if appropriate, otherwise an error.
type SyncAck ¶
type SyncAck struct{}
SyncAck is a message sent to confirm a hard synchronization, which is when the node has all the blocks.
- implements serde.Message
type SyncMessage ¶
type SyncMessage struct {
// contains filtered or unexported fields
}
SyncMessage is the announcement sent to the participants with the latest index of the leader. The chain is provided to prove the validity of the index.
- implements serde.Message
func NewSyncMessage ¶
func NewSyncMessage(chain types.Chain) SyncMessage
NewSyncMessage creates a new announcement message.
func (SyncMessage) GetChain ¶
func (m SyncMessage) GetChain() types.Chain
GetChain returns the chain that proves the latest index.
func (SyncMessage) GetLatestIndex ¶
func (m SyncMessage) GetLatestIndex() uint64
GetLatestIndex returns the latest index.
type SyncReply ¶
type SyncReply struct {
// contains filtered or unexported fields
}
SyncReply is a message to send a block to a participant.
- implements serde.Message
func NewSyncReply ¶
NewSyncReply creates a new sync reply.
type SyncRequest ¶
type SyncRequest struct {
// contains filtered or unexported fields
}
SyncRequest is a message to request missing blocks from a given index.
- implements serde.Message
func NewSyncRequest ¶
func NewSyncRequest(from uint64) SyncRequest
NewSyncRequest creates a new sync request.
func (SyncRequest) GetFrom ¶
func (m SyncRequest) GetFrom() uint64
GetFrom returns the expected index of the first block when catching up.