commands

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package commands provides commands used by the client and server.

Index

Constants

View Source
const (
	// ResponseStatusOK is an ErrorCode value used in responses from the Reunion DB
	// to indicate there was no error with the received query command.
	ResponseStatusOK = 0
	// ResponseStatusInvalidCommand is an ErrorCode value used in responses
	// from the Reunion DB to indicate the command was not accepted.
	ResponseInvalidCommand = 0xFF
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command interface {
	// ToBytes serializes the command and returns the resulting slice.
	ToBytes() []byte
}

Command interface represents query and response Reunion DB commands.

func FromBytes

func FromBytes(b []byte) (Command, error)

FromBytes de-serializes the command in the buffer b, returning a Command or an error.

type FetchState

type FetchState struct {
	// Epoch specifies the current Reunion epoch.
	Epoch uint64

	// T1Hash is the hash of the T1 message which is linked with a set of received messages.
	T1Hash [sha256.Size]byte
}

FetchState command is used by clients to fetch the current Reunion DB state.

func (*FetchState) ToBytes

func (s *FetchState) ToBytes() []byte

ToBytes serializes the SendT1 command and returns the resulting slice.

type MessageResponse

type MessageResponse struct {
	// ErrorCode indicates a specific error or status OK.
	ErrorCode uint8
}

MessageResponse command is used by the server to send clients the status of the previously received send command (SendT1, SendT2 and, SendT3).

func (*MessageResponse) ToBytes

func (s *MessageResponse) ToBytes() []byte

ToBytes serializes the MessageResponse command and returns the resulting slice.

type SendT1

type SendT1 struct {
	// Epoch specifies the current Reunion epoch.
	Epoch uint64

	// Payload contains the T1 message.
	Payload []byte
}

SendT1 command is used by clients to send their T1 message to the Reunion DB.

func (*SendT1) ToBytes

func (s *SendT1) ToBytes() []byte

ToBytes serializes the SendT1 command and returns the resulting slice.

type SendT2

type SendT2 struct {
	// Epoch specifies the current Reunion epoch.
	Epoch uint64

	// SrcT1Hash is the hash of the T1 message sent by this sender.
	SrcT1Hash [sha256.Size]byte

	// DstT1Hash is the hash of the T1 message which this T2 message is replying.
	DstT1Hash [sha256.Size]byte

	// Payload contains the T2 message.
	Payload []byte
}

SendT2 command is used by clients to send their T2 message to the Reunion DB.

func (*SendT2) ToBytes

func (s *SendT2) ToBytes() []byte

ToBytes serializes the SendT2 command and returns the resulting slice.

type SendT3

type SendT3 struct {
	// Epoch specifies the current Reunion epoch.
	Epoch uint64

	// SrcT1Hash is the hash of the T1 message sent by this sender.
	SrcT1Hash [sha256.Size]byte

	// DstT1Hash is the hash of the T1 message which this T2 message is replying.
	DstT1Hash [sha256.Size]byte

	// Payload contains the T3 message.
	Payload []byte
}

SendT3 command is used by clients to send their T3 message to the Reunion DB.

func (*SendT3) ToBytes

func (s *SendT3) ToBytes() []byte

ToBytes serializes the SendT2 command and returns the resulting slice.

type StateResponse

type StateResponse struct {
	// ErrorCode indicates a specific error or status OK.
	ErrorCode uint8
	// Truncated indicates if the payload was truncated or not.
	Truncated bool
	// LeftOverChunksHint is the number of left over chunks if
	// the payload is truncated.
	LeftOverChunksHint uint32
	// Payload contains the Reunion DB state.
	Payload []byte
}

StateResponse is sent to clients in response to a FetchState command.

func (*StateResponse) ToBytes

func (s *StateResponse) ToBytes() []byte

ToBytes serializes the SendT1 command and returns the resulting slice.

Jump to

Keyboard shortcuts

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