protocol

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

nolint

Index

Constants

View Source
const (
	// MaxFrameSize is set at 1375000 bytes.
	MaxFrameSize = uint64(1375000)

	// VersionLength is number of bytes the version uses.
	VersionLength = uint64(8)
)
View Source
const VersionConstraintString = "~0.1.0"

VersionConstraintString represent the needed version.

Variables

View Source
var CurrentProtocolVersion = semver.MustParse("0.1.0")

CurrentProtocolVersion indicates the protocol version used.

View Source
var NodeVer = &Version{
	Major: 0,
	Minor: 4,
	Patch: 3,
}

NodeVer is the current node version. This is used only in the handshake, need to be removed.

VersionConstraint check incoming versions.

Functions

func ExtractVersion added in v0.5.0

func ExtractVersion(r io.Reader) (*semver.Version, error)

ExtractVersion extracts the version from io.Reader.

func ReadFrame added in v0.4.0

func ReadFrame(r io.Reader) (uint64, error)

ReadFrame extract the bytes representing the size of the packet and thus read the amount of bytes specified by such prefix in little endianness.

func VersionAsBuffer added in v0.5.0

func VersionAsBuffer() bytes.Buffer

VersionAsBuffer returns protocol version encoded as BytesBuffer.

func WriteFrame added in v0.4.0

func WriteFrame(buf *bytes.Buffer, cs []byte) error

WriteFrame same as WriteFrameWithReserved but with reserved field fixed to 0.

func WriteFrameWithReserved added in v0.6.0

func WriteFrameWithReserved(buf *bytes.Buffer, cs []byte, reserved uint64) error

WriteFrameWithReserved mutates a buffer by adding a length-prefixing wire message frame at the beginning of the message.

Types

type Gossip added in v0.4.0

type Gossip struct {
}

Gossip is a preprocessor/reader for gossip messages.

func NewGossip added in v0.4.0

func NewGossip() *Gossip

NewGossip returns a gossip preprocessor with the specified magic.

func (*Gossip) Process added in v0.4.0

func (g *Gossip) Process(m *bytes.Buffer) error

Process same as ProcessWithReserved but with reserved field fixed to 0.

func (*Gossip) ProcessWithReserved added in v0.6.0

func (g *Gossip) ProcessWithReserved(m *bytes.Buffer, reserved uint64) error

ProcessWithReserved process a message that is passing through, by prepending magic and the message checksum, and finally by prepending the length. It allows to set reserved field.

func (*Gossip) ReadFrame added in v0.4.0

func (g *Gossip) ReadFrame(src io.Reader) ([]byte, error)

ReadFrame extract message from gossip frame, if no errors found.

func (*Gossip) ReadMessage added in v0.4.0

func (g *Gossip) ReadMessage(src io.Reader) ([]byte, error)

ReadMessage reads from the connection. TODO: Replace ReadMessage with ReadFrame.

func (*Gossip) UnpackLength added in v0.4.0

func (g *Gossip) UnpackLength(r io.Reader) (uint64, error)

UnpackLength unwraps the incoming packet (likely from a net.Conn struct) and returns the length of the packet without reading the payload (which is left to the user of this method).

type ServiceFlag

type ServiceFlag uint64

ServiceFlag indicates the services provided by the Node.

const (
	// FullNode indicates that a user is running the full node implementation of Dusk.
	FullNode ServiceFlag = 1
)

type Version

type Version struct {
	Major uint8
	Minor uint8
	Patch uint16
}

Version is a struct that separates version fields.

func (*Version) Decode

func (v *Version) Decode(r *bytes.Buffer) error

Decode will Decodde a Version struct from r.

func (*Version) Encode

func (v *Version) Encode(w *bytes.Buffer) error

Encode will encode a Version struct to w.

func (Version) String

func (v Version) String() string

Jump to

Keyboard shortcuts

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