types

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

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 ChainKey

type ChainKey struct{}

ChainKey is the key of the chain factory.

type LinkKey

type LinkKey struct{}

LinkKey is the key of the block link factory.

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

func (fac MessageFactory) Deserialize(ctx serde.Context, data []byte) (serde.Message, error)

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

func NewSyncAck

func NewSyncAck() SyncAck

NewSyncAck creates a new sync acknowledgement.

func (SyncAck) Serialize

func (m SyncAck) Serialize(ctx serde.Context) ([]byte, error)

Serialize implements serde.Message. It returns the serialized data for this 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.

func (SyncMessage) Serialize

func (m SyncMessage) Serialize(ctx serde.Context) ([]byte, error)

Serialize implements serde.Message. It returns the serialized data for this message.

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

func NewSyncReply(link types.BlockLink) SyncReply

NewSyncReply creates a new sync reply.

func (m SyncReply) GetLink() types.BlockLink

GetLink returns the link to a block to catch up.

func (SyncReply) Serialize

func (m SyncReply) Serialize(ctx serde.Context) ([]byte, error)

Serialize implements serde.Message. It returns the serialized data for this message.

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.

func (SyncRequest) Serialize

func (m SyncRequest) Serialize(ctx serde.Context) ([]byte, error)

Serialize implements serde.Message. It returns the serialized data for this message.

Jump to

Keyboard shortcuts

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