protocol

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

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

Variables

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

NodeVer is the current node version.

Functions

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 WriteFrame added in v0.4.0

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

WriteFrame 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 {
	Magic Magic
}

Gossip is a preprocessor/reader for gossip messages.

func NewGossip added in v0.4.0

func NewGossip(magic Magic) *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 a message that is passing through, by prepending magic and the message checksum, and finally by prepending the length.

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 Magic

type Magic uint8

Magic is the network that Dusk is running on.

const (
	// MainNet identifies the production network of the Dusk blockchain.
	MainNet Magic = iota
	// TestNet identifies the test network of the Dusk blockchain.
	TestNet
	// DevNet identifies the development network of the Dusk blockchain.
	DevNet
)

func Extract added in v0.2.0

func Extract(r io.Reader) (Magic, error)

Extract the magic from io.Reader. In case of unknown Magic, it returns DevNet.

func MagicFromConfig

func MagicFromConfig() Magic

MagicFromConfig reads the loaded magic config and tries to map it to magic identifier. Panic, if no match found.

func (Magic) Len added in v0.2.0

func (m Magic) Len() int

Len returns the amount of bytes of the Magic sequence.

func (Magic) String added in v0.2.0

func (m Magic) String() string

String representation of Magic.

func (Magic) ToBuffer added in v0.2.0

func (m Magic) ToBuffer() bytes.Buffer

ToBuffer returns the buffer representation of the Magic.

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