Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( HandshakeOps = []Op{ Version, PeerList, Ping, Pong, } // List of all consensus request message types ConsensusRequestOps = []Op{ GetAcceptedFrontier, GetAccepted, GetAncestors, Get, PushQuery, PullQuery, AppRequest, } ConsensusResponseOps = []Op{ AcceptedFrontier, Accepted, Ancestors, Put, Chits, AppResponse, } // AppGossip is the only message that is sent unrequested without the // expectation of a response ConsensusExternalOps = append( ConsensusRequestOps, append( ConsensusResponseOps, AppGossip, )..., ) ConsensusInternalOps = []Op{ GetAcceptedFrontierFailed, GetAcceptedFailed, GetFailed, QueryFailed, GetAncestorsFailed, AppRequestFailed, Timeout, Connected, Disconnected, Notify, GossipRequest, } ConsensusOps = append(ConsensusExternalOps, ConsensusInternalOps...) ExternalOps = append(ConsensusExternalOps, HandshakeOps...) SynchronousOps = []Op{ GetAcceptedFrontier, AcceptedFrontier, GetAccepted, Accepted, GetAncestors, Ancestors, Get, Put, PushQuery, PullQuery, Chits, GetAcceptedFrontierFailed, GetAcceptedFailed, GetFailed, QueryFailed, GetAncestorsFailed, Connected, Disconnected, } AsynchronousOps = []Op{ AppRequest, AppGossip, AppRequestFailed, AppResponse, } RequestToResponseOps = map[Op]Op{ GetAcceptedFrontier: AcceptedFrontier, GetAccepted: Accepted, GetAncestors: Ancestors, Get: Put, PushQuery: Chits, PullQuery: Chits, AppRequest: AppResponse, } ResponseToFailedOps = map[Op]Op{ AcceptedFrontier: GetAcceptedFrontierFailed, Accepted: GetAcceptedFailed, Ancestors: GetAncestorsFailed, Put: GetFailed, Chits: QueryFailed, AppResponse: AppRequestFailed, } FailedToResponseOps = map[Op]Op{ GetAcceptedFrontierFailed: AcceptedFrontier, GetAcceptedFailed: Accepted, GetAncestorsFailed: Ancestors, GetFailed: Put, QueryFailed: Chits, AppRequestFailed: AppResponse, } UnrequestedOps = map[Op]struct{}{ GetAcceptedFrontier: {}, GetAccepted: {}, GetAncestors: {}, Get: {}, PushQuery: {}, PullQuery: {}, AppRequest: {}, AppGossip: {}, } )
Functions ¶
This section is empty.
Types ¶
type Codec ¶
func NewCodecWithMemoryPool ¶
func NewCodecWithMemoryPool(namespace string, metrics prometheus.Registerer, maxMessageSize int64, maxMessageTimeout time.Duration) (Codec, error)
type Creator ¶
type Creator interface { OutboundMsgBuilder InboundMsgBuilder InternalMsgBuilder }
func NewCreator ¶
func NewCreator(metrics prometheus.Registerer, compressionEnabled bool, parentNamespace string, maxInboundMessageTimeout time.Duration) (Creator, error)
type Field ¶
type Field uint32
Field that may be packed into a message
const ( VersionStr Field = iota // Used in handshake NetworkID // Used in handshake NodeID // TODO: remove NodeID. Used in handshake MyTime // Used in handshake IP // Used in handshake ChainID // Used for dispatching RequestID // Used for all messages Deadline // Used for request messages ContainerID // Used for querying ContainerBytes // Used for gossiping ContainerIDs // Used for querying MultiContainerBytes // Used in Ancestors SigBytes // Used in handshake / peer gossiping VersionTime // Used in handshake / peer gossiping Peers // Used in peer gossiping TrackedSubnets // Used in handshake / peer gossiping AppBytes // Used at application level VMMessage // Used internally Uptime // Used for Pong VersionStruct // Used internally )
Fields that may be packed. These values are not sent over the wire.
type InboundMessage ¶
type InboundMessage interface { fmt.Stringer BytesSavedCompression() int Op() Op Get(Field) interface{} NodeID() ids.ShortID ExpirationTime() time.Time OnFinishedHandling() }
InboundMessage represents a set of fields for an inbound message that can be serialized into a byte stream
type InboundMsgBuilder ¶
type InboundMsgBuilder interface { Parser InboundGetAcceptedFrontier( chainID ids.ID, requestID uint32, deadline time.Duration, nodeID ids.ShortID, ) InboundMessage InboundAcceptedFrontier( chainID ids.ID, requestID uint32, containerIDs []ids.ID, nodeID ids.ShortID, ) InboundMessage InboundGetAccepted( chainID ids.ID, requestID uint32, deadline time.Duration, containerIDs []ids.ID, nodeID ids.ShortID, ) InboundMessage InboundAccepted( chainID ids.ID, requestID uint32, containerIDs []ids.ID, nodeID ids.ShortID, ) InboundMessage InboundAncestors( chainID ids.ID, requestID uint32, containers [][]byte, nodeID ids.ShortID, ) InboundMessage // used in UTs only InboundPushQuery( chainID ids.ID, requestID uint32, deadline time.Duration, containerID ids.ID, container []byte, nodeID ids.ShortID, ) InboundMessage InboundPullQuery( chainID ids.ID, requestID uint32, deadline time.Duration, containerID ids.ID, nodeID ids.ShortID, ) InboundMessage InboundChits( chainID ids.ID, requestID uint32, containerIDs []ids.ID, nodeID ids.ShortID, ) InboundMessage InboundAppRequest( chainID ids.ID, requestID uint32, deadline time.Duration, msg []byte, nodeID ids.ShortID, ) InboundMessage InboundAppResponse( chainID ids.ID, requestID uint32, msg []byte, nodeID ids.ShortID, ) InboundMessage InboundGet( chainID ids.ID, requestID uint32, deadline time.Duration, containerID ids.ID, nodeID ids.ShortID, ) InboundMessage InboundPut( chainID ids.ID, requestID uint32, containerID ids.ID, container []byte, nodeID ids.ShortID, ) InboundMessage // used in UTs only }
func NewInboundBuilder ¶
func NewInboundBuilder(c Codec) InboundMsgBuilder
type InternalMsgBuilder ¶
type InternalMsgBuilder interface { InternalFailedRequest( op Op, nodeID ids.ShortID, chainID ids.ID, requestID uint32, ) InboundMessage InternalTimeout(nodeID ids.ShortID) InboundMessage InternalConnected(nodeID ids.ShortID, nodeVersion version.Application) InboundMessage InternalDisconnected(nodeID ids.ShortID) InboundMessage InternalVMMessage(nodeID ids.ShortID, notification uint32) InboundMessage InternalGossipRequest(nodeID ids.ShortID) InboundMessage }
func NewInternalBuilder ¶
func NewInternalBuilder() InternalMsgBuilder
type Op ¶
type Op byte
Op is an opcode
const ( Pong Op Ping // Bootstrapping: GetAcceptedFrontier AcceptedFrontier GetAccepted Accepted GetAncestors Ancestors // Consensus: Get Put PushQuery PullQuery Chits PeerList Version // Application level: AppRequest AppResponse AppGossip // Internal messages (External messages should be added above these): GetAcceptedFrontierFailed GetAcceptedFailed GetFailed QueryFailed GetAncestorsFailed AppRequestFailed Timeout Connected Disconnected Notify GossipRequest )
Types of messages that may be sent between nodes Note: If you add a new parseable Op below, you must also add it to ops (declared below)
"_" are used in places where old message types were defined that are no longer supported. When new messages are introduced these values are typically safe to reuse.
func (Op) Compressible ¶ added in v1.7.6
type OutboundMessage ¶
type OutboundMessage interface { BytesSavedCompression() int Bytes() []byte Op() Op BypassThrottling() bool AddRef() DecRef() }
OutboundMessage represents a set of fields for an outbound message that can be serialized into a byte stream
type OutboundMsgBuilder ¶
type OutboundMsgBuilder interface { Version( networkID uint32, myTime uint64, ip utils.IPDesc, myVersion string, myVersionTime uint64, sig []byte, trackedSubnets []ids.ID, ) (OutboundMessage, error) PeerList( peers []utils.IPCertDesc, bypassThrottling bool, ) (OutboundMessage, error) Ping() (OutboundMessage, error) Pong(uptimePercentage uint8) (OutboundMessage, error) GetAcceptedFrontier( chainID ids.ID, requestID uint32, deadline time.Duration, ) (OutboundMessage, error) AcceptedFrontier( chainID ids.ID, requestID uint32, containerIDs []ids.ID, ) (OutboundMessage, error) GetAccepted( chainID ids.ID, requestID uint32, deadline time.Duration, containerIDs []ids.ID, ) (OutboundMessage, error) Accepted( chainID ids.ID, requestID uint32, containerIDs []ids.ID, ) (OutboundMessage, error) GetAncestors( chainID ids.ID, requestID uint32, deadline time.Duration, containerID ids.ID, ) (OutboundMessage, error) Ancestors( chainID ids.ID, requestID uint32, containers [][]byte, ) (OutboundMessage, error) Get( chainID ids.ID, requestID uint32, deadline time.Duration, containerID ids.ID, ) (OutboundMessage, error) Put( chainID ids.ID, requestID uint32, containerID ids.ID, container []byte, ) (OutboundMessage, error) PushQuery( chainID ids.ID, requestID uint32, deadline time.Duration, containerID ids.ID, container []byte, ) (OutboundMessage, error) PullQuery( chainID ids.ID, requestID uint32, deadline time.Duration, containerID ids.ID, ) (OutboundMessage, error) Chits( chainID ids.ID, requestID uint32, containerIDs []ids.ID, ) (OutboundMessage, error) AppRequest( chainID ids.ID, requestID uint32, deadline time.Duration, msg []byte, ) (OutboundMessage, error) AppResponse( chainID ids.ID, requestID uint32, msg []byte, ) (OutboundMessage, error) AppGossip( chainID ids.ID, msg []byte, ) (OutboundMessage, error) }
OutboundMsgBuilder builds outbound messages. Outbound messages are returned with a reference count of 1. Once the reference count hits 0, the message bytes should no longer be accessed.
func NewOutboundBuilder ¶
func NewOutboundBuilder(c Codec, enableCompression bool) OutboundMsgBuilder
type TestMsg ¶ added in v1.7.6
type TestMsg struct {
// contains filtered or unexported fields
}