transport

package
v0.0.0-...-237c5c3 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const TAG_AUTH = 14
View Source
const TAG_AUTH_DATA = 15
View Source
const TAG_BEGIN = 16
View Source
const TAG_BYE = 17
View Source
const TAG_DATA = 2
View Source
const TAG_DATA_ACK = 3
View Source
const TAG_DATA_REJECT = 4
View Source
const TAG_HELLO = 12
View Source
const TAG_NODE_DETAILS = 20
View Source
const TAG_NODE_REQUEST = 19
View Source
const TAG_NODE_SUMMARY = 18
View Source
const TAG_OK = 10
View Source
const TAG_PING = 0
View Source
const TAG_PONG = 1
View Source
const TAG_REJECT = 11
View Source
const TAG_SELECT = 13

Variables

View Source
var ErrUnknownPeerMessage error = errors.New("unknown peer message")

Functions

func DecodeBinaryPeerMessage

func DecodeBinaryPeerMessage(reader io.Reader) (m interface{}, err error)

func EncodeBinaryPeerMessage

func EncodeBinaryPeerMessage(data interface{}, target io.Writer) (err error)

EncodeBinaryPeerMessage takes a peer message and turns it into

Types

type AuthDataMessage

type AuthDataMessage struct {
	Data []byte
}

AuthDataMessage contains additional data as needed for a specific authentication method

type AuthMessage

type AuthMessage struct {
	// Method of authentication picked
	Method string

	// Data associated with the
	Data []byte
}

AuthMessage is sent to pick how to authenticate with a remote peer

type BeginMessage

type BeginMessage struct{}

BeginMessage is sent when a connection is negotiated and should be established

type ByeMessage

type ByeMessage struct{}

ByeMessage indicates that a disconnect should occur

type DataAckMessage

type DataAckMessage struct {
	// Id of data acknowledged
	Id int32
}

DataAckMessage is used when a node has handled a certain data message, either by consuming it or by forwarding it and receiving a reply

type DataMessage

type DataMessage struct {
	// Path describes the current path for the data. Nodes append their
	// id here which is used to make sure send loops are avoided
	Path []DataMessagePathEntry

	// Target is the node that this message should eventually reach
	Target NodeId

	// Type of data
	Type string

	// Data is the binary representation of the data
	Data []byte
}

DataMessage contains data intended for a certain node

type DataMessagePathEntry

type DataMessagePathEntry struct {
	// Node is the id of the node this passed through
	Node NodeId

	// Id is a local identifier used to keep track of the message
	Id int32
}

DataMessagePathEntry holds information about the a node and id pair

type DataRejectMessage

type DataRejectMessage struct {
	// Id of data rejected
	Id int32
}

DataRejectMessage is used when a node can not handle a certain data message

type HelloMessage

type HelloMessage struct {
	// Identifier of this peer
	Id NodeId

	// Capabilities picked, used to negotiate protocol versions and features
	Capabilities []string
}

HelloMessage is the first message sent when trying to establish a connection with another peer

type NodeDetailsMessage

type NodeDetailsMessage struct {
	// Nodes contains the requested routing details
	Nodes []NodeRoutingDetails
}

NodeDetailsMessage is the reply to a NodeRequestMessage and contains detailed information about the nodes

type NodeId

type NodeId []byte

type NodeRequestMessage

type NodeRequestMessage struct {
	// Nodes to fetch information for
	Nodes []NodeId
}

NodeRequestMessage is used to request information about nodes from a peer

type NodeRoutingDetails

type NodeRoutingDetails struct {
	// Id of this node
	Id NodeId

	// Version of this node
	Version int32

	// Neighbors that this node can see
	Neighbors []NodeWithLatency
}

NodeRoutingDetails carries detailed routing information for a specific node

type NodeRoutingsummary

type NodeRoutingsummary struct {
	// Id is the identifier of the Node
	Id NodeId

	// Version is the version of the routing, this is used to request more
	// information if the local version differs
	Version int32
}

NodeRoutingSummary is a summary of a Node id and routing version

type NodeSummaryMessage

type NodeSummaryMessage struct {
	// OwnVersion represents the version of this routing. This will increase
	// if detects changes in peers around it
	OwnVersion int32

	// Nodes contains a summary of routing for all the nodes the peer can see
	Nodes []NodeRoutingsummary
}

NodeSummaryMessage contains information about the nodes a peer can see

type NodeWithLatency

type NodeWithLatency struct {
	// Id of the node
	Id NodeId
	// Latency in milliseconds
	Latency int32
}

NodeWithLatency describes the latency to a neighbor as seen by a certain node

type OkMessage

type OkMessage struct{}

OkMessage is sent for certain operations during the handshake

type Peer

type Peer struct {
}

func (*Peer) Id

func (p *Peer) Id() []byte

func (*Peer) NotifyConnect

func (p *Peer) NotifyConnect(c chan *Peer) chan *Peer

type PingMessage

type PingMessage struct{}

PingMessage is sent to peers to do a liveness check

type PongMessage

type PongMessage struct{}

PongMessage is the reply sent for PingMessage

type RejectMessage

type RejectMessage struct{}

RejectMessage is sent for certain operations during the handshake

type SelectMessage

type SelectMessage struct {
	// Identifier of this peer
	Id NodeId

	// Capabilities picked from the set sent in Hello
	Capabilities []string
}

SelectMesage is sent as a reply to a Hello indicating the id of the remote peer and the capabilities it picked

Jump to

Keyboard shortcuts

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