Documentation ¶
Index ¶
- Constants
- Variables
- func EventId(channel channels.Channel, payload []byte) (hash.Hash, error)
- func IsUnknownMsgTypeErr(err error) bool
- func MessageType(decodedPayload interface{}) string
- func NewUnauthorizedProtocolError(p ProtocolType) error
- type ChannelAuthConfig
- type IncomingMessageScope
- func (m IncomingMessageScope) Channel() channels.Channel
- func (m IncomingMessageScope) DecodedPayload() interface{}
- func (m IncomingMessageScope) EventID() []byte
- func (m IncomingMessageScope) OriginId() flow.Identifier
- func (m IncomingMessageScope) PayloadType() string
- func (m IncomingMessageScope) Proto() *Message
- func (m IncomingMessageScope) Protocol() ProtocolType
- func (m IncomingMessageScope) Size() int
- func (m IncomingMessageScope) TargetIDs() flow.IdentifierList
- type Message
- func (*Message) Descriptor() ([]byte, []int)
- func (m *Message) GetChannelID() string
- func (m *Message) GetPayload() []byte
- func (m *Message) GetTargetIDs() [][]byte
- func (m *Message) Marshal() (dAtA []byte, err error)
- func (m *Message) MarshalTo(dAtA []byte) (int, error)
- func (m *Message) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Message) ProtoMessage()
- func (m *Message) Reset()
- func (m *Message) Size() (n int)
- func (m *Message) String() string
- func (m *Message) Unmarshal(dAtA []byte) error
- func (m *Message) XXX_DiscardUnknown()
- func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Message) XXX_Merge(src proto.Message)
- func (m *Message) XXX_Size() int
- func (m *Message) XXX_Unmarshal(b []byte) error
- type MsgAuthConfig
- type OutgoingMessageScope
- type PingRequest
- func (*PingRequest) Descriptor() ([]byte, []int)
- func (m *PingRequest) Marshal() (dAtA []byte, err error)
- func (m *PingRequest) MarshalTo(dAtA []byte) (int, error)
- func (m *PingRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*PingRequest) ProtoMessage()
- func (m *PingRequest) Reset()
- func (m *PingRequest) Size() (n int)
- func (m *PingRequest) String() string
- func (m *PingRequest) Unmarshal(dAtA []byte) error
- func (m *PingRequest) XXX_DiscardUnknown()
- func (m *PingRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *PingRequest) XXX_Merge(src proto.Message)
- func (m *PingRequest) XXX_Size() int
- func (m *PingRequest) XXX_Unmarshal(b []byte) error
- type PingResponse
- func (*PingResponse) Descriptor() ([]byte, []int)
- func (m *PingResponse) GetBlockHeight() uint64
- func (m *PingResponse) GetHotstuffView() uint64
- func (m *PingResponse) GetVersion() string
- func (m *PingResponse) Marshal() (dAtA []byte, err error)
- func (m *PingResponse) MarshalTo(dAtA []byte) (int, error)
- func (m *PingResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*PingResponse) ProtoMessage()
- func (m *PingResponse) Reset()
- func (m *PingResponse) Size() (n int)
- func (m *PingResponse) String() string
- func (m *PingResponse) Unmarshal(dAtA []byte) error
- func (m *PingResponse) XXX_DiscardUnknown()
- func (m *PingResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *PingResponse) XXX_Merge(src proto.Message)
- func (m *PingResponse) XXX_Size() int
- func (m *PingResponse) XXX_Unmarshal(b []byte) error
- type ProtocolType
- type Protocols
- type UnknownMsgTypeErr
Constants ¶
const ( BlockProposal = "BlockProposal" BlockVote = "BlockVote" TimeoutObject = "Timeout" SyncRequest = "SyncRequest" SyncResponse = "SyncResponse" RangeRequest = "RangeRequest" BatchRequest = "BatchRequest" BlockResponse = "BlockResponse" ClusterBlockProposal = "ClusterBlockProposal" ClusterBlockVote = "ClusterBlockVote" ClusterTimeoutObject = "ClusterTimeout" ClusterBlockResponse = "ClusterBlockResponse" CollectionGuarantee = "CollectionGuarantee" TransactionBody = "TransactionBody" ExecutionReceipt = "ExecutionReceipt" ResultApproval = "ResultApproval" ChunkDataRequest = "ChunkDataRequest" ChunkDataResponse = "ChunkDataResponse" ApprovalRequest = "ApprovalRequest" ApprovalResponse = "ApprovalResponse" EntityRequest = "EntityRequest" EntityResponse = "EntityResponse" TestMessage = "TestMessage" DKGMessage = "DKGMessage" )
string constants for all message types sent on the network
Variables ¶
var ()
Functions ¶
func EventId ¶ added in v0.32.0
EventId computes the event ID for a given channel and payload (i.e., the hash of the payload and channel). All errors returned by this function are benign and should not cause the node to crash. It errors if the hash function fails to hash the payload and channel.
func IsUnknownMsgTypeErr ¶ added in v0.27.0
IsUnknownMsgTypeErr returns whether an error is UnknownMsgTypeErr
func MessageType ¶ added in v0.32.0
func MessageType(decodedPayload interface{}) string
MessageType returns the type of the message payload.
func NewUnauthorizedProtocolError ¶ added in v0.29.0
func NewUnauthorizedProtocolError(p ProtocolType) error
NewUnauthorizedProtocolError returns ErrUnauthorizedUnicastOnChannel or ErrUnauthorizedPublishOnChannel depending on the protocol provided.
Types ¶
type ChannelAuthConfig ¶ added in v0.29.0
type ChannelAuthConfig struct { // AuthorizedRoles list of roles authorized to send this message on the channel. AuthorizedRoles flow.RoleList // AllowedProtocols list of protocols the message is allowed to be sent on. Currently AllowedProtocols is expected to have // exactly one element in the list. This is due to the fact that currently there are no messages that are used with both protocols aside from TestMessage. AllowedProtocols Protocols }
type IncomingMessageScope ¶ added in v0.32.0
type IncomingMessageScope struct {
// contains filtered or unexported fields
}
IncomingMessageScope captures the context around an incoming message that is received by the network layer.
func NewIncomingScope ¶ added in v0.32.0
func NewIncomingScope(originId flow.Identifier, protocol ProtocolType, msg *Message, decodedPayload interface{}) (*IncomingMessageScope, error)
NewIncomingScope creates a new incoming message scope. All errors returned by this function are benign and should not cause the node to crash, especially that it is not safe to crash the node when receiving a message. It errors if event id (i.e., hash of the payload and channel) cannot be computed, or if it fails to convert the target IDs from bytes slice to a flow.IdentifierList.
func (IncomingMessageScope) Channel ¶ added in v0.32.0
func (m IncomingMessageScope) Channel() channels.Channel
func (IncomingMessageScope) DecodedPayload ¶ added in v0.32.0
func (m IncomingMessageScope) DecodedPayload() interface{}
func (IncomingMessageScope) EventID ¶ added in v0.32.0
func (m IncomingMessageScope) EventID() []byte
func (IncomingMessageScope) OriginId ¶ added in v0.32.0
func (m IncomingMessageScope) OriginId() flow.Identifier
func (IncomingMessageScope) PayloadType ¶ added in v0.32.0
func (m IncomingMessageScope) PayloadType() string
func (IncomingMessageScope) Proto ¶ added in v0.32.0
func (m IncomingMessageScope) Proto() *Message
func (IncomingMessageScope) Protocol ¶ added in v0.32.0
func (m IncomingMessageScope) Protocol() ProtocolType
func (IncomingMessageScope) Size ¶ added in v0.32.0
func (m IncomingMessageScope) Size() int
func (IncomingMessageScope) TargetIDs ¶ added in v0.32.0
func (m IncomingMessageScope) TargetIDs() flow.IdentifierList
type Message ¶
type Message struct { ChannelID string `protobuf:"bytes,1,opt,name=ChannelID,proto3" json:"ChannelID,omitempty"` TargetIDs [][]byte `protobuf:"bytes,2,rep,name=TargetIDs,proto3" json:"TargetIDs,omitempty"` Payload []byte `protobuf:"bytes,3,opt,name=Payload,proto3" json:"Payload,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
Message models a single message that is supposed to get exchanged by the gossip network
func (*Message) Descriptor ¶
func (*Message) GetChannelID ¶
func (*Message) GetPayload ¶
func (*Message) GetTargetIDs ¶
func (*Message) MarshalToSizedBuffer ¶
func (*Message) ProtoMessage ¶
func (*Message) ProtoMessage()
func (*Message) XXX_DiscardUnknown ¶
func (m *Message) XXX_DiscardUnknown()
func (*Message) XXX_Marshal ¶
func (*Message) XXX_Unmarshal ¶
type MsgAuthConfig ¶ added in v0.27.0
type MsgAuthConfig struct { // Name is the string representation of the message type. Name string // Type is a func that returns a new instance of message type. Type func() interface{} // Config is the mapping of network channel to list of authorized flow roles. Config map[channels.Channel]ChannelAuthConfig }
MsgAuthConfig contains authorization information for a specific flow message. The authorization is represented as a map from network channel -> list of all roles allowed to send the message on the channel.
func GetAllMessageAuthConfigs ¶ added in v0.27.0
func GetAllMessageAuthConfigs() []MsgAuthConfig
GetAllMessageAuthConfigs returns all the configured message auth configurations.
func GetMessageAuthConfig ¶ added in v0.27.0
func GetMessageAuthConfig(v interface{}) (MsgAuthConfig, error)
GetMessageAuthConfig checks the underlying type and returns the correct message auth Config. Expected error returns during normal operations:
- ErrUnknownMsgType : if underlying type of v does not match any of the known message types
func (MsgAuthConfig) EnsureAuthorized ¶ added in v0.27.0
func (m MsgAuthConfig) EnsureAuthorized(role flow.Role, channel channels.Channel, protocol ProtocolType) error
EnsureAuthorized checks if the specified role is authorized to send the message on the provided channel and asserts that the message is authorized to be sent on the channel. Expected error returns during normal operations:
- ErrUnauthorizedMessageOnChannel: the channel is not included in the message's list of authorized channels
- ErrUnauthorizedRole: the role is not included in the message's list of authorized roles for the provided channel
- ErrUnauthorizedUnicastOnChannel: the message is not authorized to be sent via unicast protocol.
- ErrUnauthorizedPublishOnChannel: the message is not authorized to be sent via publish protocol.
type OutgoingMessageScope ¶ added in v0.32.0
type OutgoingMessageScope struct {
// contains filtered or unexported fields
}
OutgoingMessageScope captures the context around an outgoing message that is about to be sent.
func NewOutgoingScope ¶ added in v0.32.0
func NewOutgoingScope( targetIds flow.IdentifierList, topic channels.Topic, payload interface{}, encoder func(interface{}) ([]byte, error), protocolType ProtocolType) (*OutgoingMessageScope, error)
NewOutgoingScope creates a new outgoing message scope. All errors returned by this function are benign and should not cause the node to crash. It errors if the encoder fails to encode the payload into a protobuf message, or if the number of target IDs does not match the protocol type (i.e., unicast messages should have exactly one target ID, while pubsub messages should have at least one target ID).
func (OutgoingMessageScope) PayloadType ¶ added in v0.32.0
func (o OutgoingMessageScope) PayloadType() string
func (OutgoingMessageScope) Proto ¶ added in v0.32.0
func (o OutgoingMessageScope) Proto() *Message
func (OutgoingMessageScope) Size ¶ added in v0.32.0
func (o OutgoingMessageScope) Size() int
func (OutgoingMessageScope) TargetIds ¶ added in v0.32.0
func (o OutgoingMessageScope) TargetIds() flow.IdentifierList
func (OutgoingMessageScope) Topic ¶ added in v0.32.0
func (o OutgoingMessageScope) Topic() channels.Topic
type PingRequest ¶ added in v0.17.0
type PingRequest struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*PingRequest) Descriptor ¶ added in v0.17.0
func (*PingRequest) Descriptor() ([]byte, []int)
func (*PingRequest) Marshal ¶ added in v0.17.0
func (m *PingRequest) Marshal() (dAtA []byte, err error)
func (*PingRequest) MarshalTo ¶ added in v0.17.0
func (m *PingRequest) MarshalTo(dAtA []byte) (int, error)
func (*PingRequest) MarshalToSizedBuffer ¶ added in v0.17.0
func (m *PingRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*PingRequest) ProtoMessage ¶ added in v0.17.0
func (*PingRequest) ProtoMessage()
func (*PingRequest) Reset ¶ added in v0.17.0
func (m *PingRequest) Reset()
func (*PingRequest) Size ¶ added in v0.17.0
func (m *PingRequest) Size() (n int)
func (*PingRequest) String ¶ added in v0.17.0
func (m *PingRequest) String() string
func (*PingRequest) Unmarshal ¶ added in v0.17.0
func (m *PingRequest) Unmarshal(dAtA []byte) error
func (*PingRequest) XXX_DiscardUnknown ¶ added in v0.17.0
func (m *PingRequest) XXX_DiscardUnknown()
func (*PingRequest) XXX_Marshal ¶ added in v0.17.0
func (m *PingRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*PingRequest) XXX_Merge ¶ added in v0.17.0
func (m *PingRequest) XXX_Merge(src proto.Message)
func (*PingRequest) XXX_Size ¶ added in v0.17.0
func (m *PingRequest) XXX_Size() int
func (*PingRequest) XXX_Unmarshal ¶ added in v0.17.0
func (m *PingRequest) XXX_Unmarshal(b []byte) error
type PingResponse ¶ added in v0.17.0
type PingResponse struct { Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` BlockHeight uint64 `protobuf:"varint,2,opt,name=blockHeight,proto3" json:"blockHeight,omitempty"` HotstuffView uint64 `protobuf:"varint,3,opt,name=hotstuffView,proto3" json:"hotstuffView,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*PingResponse) Descriptor ¶ added in v0.17.0
func (*PingResponse) Descriptor() ([]byte, []int)
func (*PingResponse) GetBlockHeight ¶ added in v0.17.0
func (m *PingResponse) GetBlockHeight() uint64
func (*PingResponse) GetHotstuffView ¶ added in v0.22.10
func (m *PingResponse) GetHotstuffView() uint64
func (*PingResponse) GetVersion ¶ added in v0.17.0
func (m *PingResponse) GetVersion() string
func (*PingResponse) Marshal ¶ added in v0.17.0
func (m *PingResponse) Marshal() (dAtA []byte, err error)
func (*PingResponse) MarshalTo ¶ added in v0.17.0
func (m *PingResponse) MarshalTo(dAtA []byte) (int, error)
func (*PingResponse) MarshalToSizedBuffer ¶ added in v0.17.0
func (m *PingResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*PingResponse) ProtoMessage ¶ added in v0.17.0
func (*PingResponse) ProtoMessage()
func (*PingResponse) Reset ¶ added in v0.17.0
func (m *PingResponse) Reset()
func (*PingResponse) Size ¶ added in v0.17.0
func (m *PingResponse) Size() (n int)
func (*PingResponse) String ¶ added in v0.17.0
func (m *PingResponse) String() string
func (*PingResponse) Unmarshal ¶ added in v0.17.0
func (m *PingResponse) Unmarshal(dAtA []byte) error
func (*PingResponse) XXX_DiscardUnknown ¶ added in v0.17.0
func (m *PingResponse) XXX_DiscardUnknown()
func (*PingResponse) XXX_Marshal ¶ added in v0.17.0
func (m *PingResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*PingResponse) XXX_Merge ¶ added in v0.17.0
func (m *PingResponse) XXX_Merge(src proto.Message)
func (*PingResponse) XXX_Size ¶ added in v0.17.0
func (m *PingResponse) XXX_Size() int
func (*PingResponse) XXX_Unmarshal ¶ added in v0.17.0
func (m *PingResponse) XXX_Unmarshal(b []byte) error
type ProtocolType ¶ added in v0.30.0
type ProtocolType string
ProtocolType defines the type of the protocol a message is sent over. Currently, we have two types of protocols: - unicast: a message is sent to a single node through a direct connection. - pubsub: a message is sent to one or more nodes through a pubsub channel.
const ( // ProtocolTypeUnicast is protocol type for unicast messages. ProtocolTypeUnicast ProtocolType = "unicast" // ProtocolTypePubSub is the protocol type for pubsub messages. ProtocolTypePubSub ProtocolType = "pubsub" )
func (ProtocolType) String ¶ added in v0.30.0
func (m ProtocolType) String() string
type Protocols ¶ added in v0.29.0
type Protocols []ProtocolType
func (Protocols) Contains ¶ added in v0.29.0
func (pr Protocols) Contains(protocol ProtocolType) bool
Contains returns true if the protocol is in the list of Protocols.
type UnknownMsgTypeErr ¶ added in v0.27.0
type UnknownMsgTypeErr struct {
MsgType interface{}
}
UnknownMsgTypeErr indicates that no message auth configured for the message type v
func NewUnknownMsgTypeErr ¶ added in v0.27.0
func NewUnknownMsgTypeErr(msgType interface{}) UnknownMsgTypeErr
NewUnknownMsgTypeErr returns a new ErrUnknownMsgType
func (UnknownMsgTypeErr) Error ¶ added in v0.27.0
func (e UnknownMsgTypeErr) Error() string