package types
import "go.dedis.ch/dela/mino/router/tree/types"
Package types implements the packet and handshake messages for the tree routing algorithm.
The messages have been implemented in this isolated package so that it does not create cycle imports when importing the serde formats.
Documentation Last Review: 06.10.2020
Index ¶
- func RegisterHandshakeFormat(f serde.Format, e serde.FormatEngine)
- func RegisterPacketFormat(c serde.Format, f serde.FormatEngine)
- type AddrKey
- type Handshake
- func NewHandshake(height int, expected ...mino.Address) Handshake
- func (h Handshake) GetAddresses() []mino.Address
- func (h Handshake) GetHeight() int
- func (h Handshake) Serialize(ctx serde.Context) ([]byte, error)
- type HandshakeFactory
- func NewHandshakeFactory(addrFac mino.AddressFactory) HandshakeFactory
- func (fac HandshakeFactory) Deserialize(ctx serde.Context, data []byte) (serde.Message, error)
- func (fac HandshakeFactory) HandshakeOf(ctx serde.Context, data []byte) (router.Handshake, error)
- type Packet
- func NewPacket(src mino.Address, msg []byte, dest ...mino.Address) *Packet
- func (p *Packet) Add(to mino.Address)
- func (p *Packet) GetDestination() []mino.Address
- func (p *Packet) GetMessage() []byte
- func (p *Packet) GetSource() mino.Address
- func (p *Packet) Serialize(ctx serde.Context) ([]byte, error)
- func (p *Packet) Slice(addr mino.Address) router.Packet
- type PacketFactory
Functions ¶
func RegisterHandshakeFormat ¶
func RegisterHandshakeFormat(f serde.Format, e serde.FormatEngine)
RegisterHandshakeFormat registers the engine for the provided format.
func RegisterPacketFormat ¶
func RegisterPacketFormat(c serde.Format, f serde.FormatEngine)
RegisterPacketFormat registers the engine for the provided format.
Types ¶
type AddrKey ¶
type AddrKey struct{}
AddrKey is the key for the address factory.
type Handshake ¶
type Handshake struct {
// contains filtered or unexported fields
}
Handshake is a message to send the initial parameters of a routing table.
- implements serde.Message
func NewHandshake ¶
NewHandshake returns a new handshake message.
func (Handshake) GetAddresses ¶
GetAddresses returns the list of addresses to route.
func (Handshake) GetHeight ¶
GetHeight returns the maximum height of the tree.
func (Handshake) Serialize ¶
Serialize implements serde.Message. It returns the serialized data for the handshake.
type HandshakeFactory ¶
type HandshakeFactory struct {
// contains filtered or unexported fields
}
HandshakeFactory is a factory to serialize and deserialize handshake messages.
- implements router.HandshakeFactory
func NewHandshakeFactory ¶
func NewHandshakeFactory(addrFac mino.AddressFactory) HandshakeFactory
NewHandshakeFactory creates a new factory.
func (HandshakeFactory) Deserialize ¶
Deserialize implements serde.Factory. It populates the handshake if appropriate, otherwise it returns an error.
func (HandshakeFactory) HandshakeOf ¶
HandshakeOf implements router.HandshakeFactory. It populates the handshake if appropriate, otherwise it returns an error.
type Packet ¶
type Packet struct {
// contains filtered or unexported fields
}
Packet describes a tree routing packet
- implements router.Packet
func NewPacket ¶
NewPacket creates a new packet.
func (*Packet) Add ¶
Add appends the address to the destination list, only if it does not exist already.
func (*Packet) GetDestination ¶
GetDestination implements router.Packet. It returns a list of addresses where the packet should be send to.
func (*Packet) GetMessage ¶
GetMessage implements router.Packet. It returns the byte buffer of the message.
func (*Packet) GetSource ¶
GetSource implements router.Packet. It returns the source address of the packet.
func (*Packet) Serialize ¶
Serialize implements serde.Message. It returns the serialized data of the packet.
func (*Packet) Slice ¶
Slice implements router.Packet. It removes the address from the destination list and returns a packet with this single destination, if it exists. Otherwise the packet stays unchanged.
type PacketFactory ¶
type PacketFactory struct {
// contains filtered or unexported fields
}
PacketFactory is a factory for the packet.
- implements serde.Factory
func NewPacketFactory ¶
func NewPacketFactory(f mino.AddressFactory) PacketFactory
NewPacketFactory returns a factory for the packet.
func (PacketFactory) Deserialize ¶
Deserialize implements serde.Factory. It populates the packet associated with the data if appropriate, otherwise it returns an error.
func (PacketFactory) PacketOf ¶
PacketOf implements router.PacketFactory. It populates the packet associated with the data if appropriate, otherwise it returns an error.
Source Files ¶
handshake.go packet.go types.go
- Version
- v0.1.0 (latest)
- Published
- Apr 10, 2024
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 1 month ago –
Tools for package owners.