Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeBinaryPeerMessage(reader io.Reader) (m interface{}, err error)
- func EncodeBinaryPeerMessage(data interface{}, target io.Writer) (err error)
- type AuthDataMessage
- type AuthMessage
- type BeginMessage
- type ByeMessage
- type DataAckMessage
- type DataMessage
- type DataMessagePathEntry
- type DataRejectMessage
- type HelloMessage
- type NodeDetailsMessage
- type NodeId
- type NodeRequestMessage
- type NodeRoutingDetails
- type NodeRoutingsummary
- type NodeSummaryMessage
- type NodeWithLatency
- type OkMessage
- type Peer
- type PingMessage
- type PongMessage
- type RejectMessage
- type SelectMessage
Constants ¶
const TAG_AUTH = 14
const TAG_AUTH_DATA = 15
const TAG_BEGIN = 16
const TAG_BYE = 17
const TAG_DATA = 2
const TAG_DATA_ACK = 3
const TAG_DATA_REJECT = 4
const TAG_HELLO = 12
const TAG_NODE_DETAILS = 20
const TAG_NODE_REQUEST = 19
const TAG_NODE_SUMMARY = 18
const TAG_OK = 10
const TAG_PING = 0
const TAG_PONG = 1
const TAG_REJECT = 11
const TAG_SELECT = 13
Variables ¶
var ErrUnknownPeerMessage error = errors.New("unknown peer message")
Functions ¶
func DecodeBinaryPeerMessage ¶
func EncodeBinaryPeerMessage ¶
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 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 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 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