relay

package
v1.1.1-0...-7cefdf7 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() *block

New sets up and returns a new Relay block instance.

func ToPeer

func ToPeer(node *noise.Node, msg Message, doLookUp, incrementSeqNum bool) error

ToPeer relays a message to peer synchronously.

Types

type Message

type Message struct {
	From      kad.ID
	To        kad.ID
	Hash      [hashSize]byte // TODO: Hash should be a method, not a field, since nodes should independently compute the hashes to be safe.
	SeenPeers []byte
	// Code is a single byte that indicates the type of Data so that Data can be properly deserialized.
	Code byte
	Data []byte
	// SeqNum is an incrementing sequence number (which wraps around 255, since it is of type byte). Messages with identical Code and Data but different SeqNums will hash differently.
	SeqNum byte
}

Message is a message with typed payload (Code and Data) to be relayed from From to To.

func NewMessage

func NewMessage(from kad.ID, to kad.ID, code byte, data []byte) Message

NewMessage creates a new Message instance.

func (*Message) ChangeSeqNum

func (msg *Message) ChangeSeqNum(newSeqNum byte)

ChangeSeqNum changes the message sequence number and rehashes the message.

func (Message) Read

func (msg Message) Read(reader payload.Reader) (noise.Message, error)

func (Message) Write

func (msg Message) Write() []byte

Jump to

Keyboard shortcuts

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