Documentation ¶
Overview ¶
Package protocol provides the common functionality for mini-protocols
Index ¶
- Constants
- Variables
- func GetProtocolVersionsNtC() []uint16
- func GetProtocolVersionsNtN() []uint16
- type Message
- type MessageBase
- type MessageFromCborFunc
- type MessageHandlerFunc
- type NewVersionDataFromCborFunc
- type Protocol
- type ProtocolConfig
- type ProtocolMode
- type ProtocolOptions
- type ProtocolRole
- type ProtocolStateAgency
- type ProtocolVersion
- type ProtocolVersionMap
- type State
- type StateMap
- type StateMapEntry
- type StateTransition
- type StateTransitionMatchFunc
- type VersionData
- func NewVersionDataNtC15andUpFromCbor(cborData []byte) (VersionData, error)
- func NewVersionDataNtC9to14FromCbor(cborData []byte) (VersionData, error)
- func NewVersionDataNtN11to12FromCbor(cborData []byte) (VersionData, error)
- func NewVersionDataNtN13andUpFromCbor(cborData []byte) (VersionData, error)
- func NewVersionDataNtN7to10FromCbor(cborData []byte) (VersionData, error)
- type VersionDataNtC15andUp
- type VersionDataNtC9to14
- type VersionDataNtN11to12
- type VersionDataNtN13andUp
- type VersionDataNtN7to10
Constants ¶
const ( DiffusionModeInitiatorOnly = true DiffusionModeInitiatorAndResponder = false )
Diffusion modes
const ( PeerSharingModeNoPeerSharing = 0 PeerSharingModePeerSharingPublic = 1 PeerSharingModeV11NoPeerSharing = 0 PeerSharingModeV11PeerSharingPrivate = 1 PeerSharingModeV11PeerSharingPublic = 2 )
Peer sharing modes
const ( QueryModeDisabled = false QueryModeEnabled = true )
Query modes
const ProtocolVersionNtCOffset = 0x8000
The NtC protocol versions have the 15th bit set in the handshake
Variables ¶
var ProtocolShuttingDownError = fmt.Errorf("protocol is shutting down")
Functions ¶
func GetProtocolVersionsNtC ¶ added in v0.63.0
func GetProtocolVersionsNtC() []uint16
GetProtocolVersionsNtC returns a list of supported NtC protocol versions
func GetProtocolVersionsNtN ¶ added in v0.63.0
func GetProtocolVersionsNtN() []uint16
GetProtocolVersionsNtN returns a list of supported NtN protocol versions
Types ¶
type MessageBase ¶
type MessageBase struct { MessageType uint8 // contains filtered or unexported fields }
MessageBase is the minimum implementation for a mini-protocol message
func (*MessageBase) Cbor ¶
func (m *MessageBase) Cbor() []byte
Cbor returns the original CBOR that was parsed
func (*MessageBase) SetCbor ¶
func (m *MessageBase) SetCbor(data []byte)
SetCbor stores the original CBOR that was parsed
type MessageFromCborFunc ¶
MessageFromCborFunc represents a function that parses a mini-protocol message
type MessageHandlerFunc ¶
MessageHandlerFunc represents a function that handles an incoming message
type NewVersionDataFromCborFunc ¶ added in v0.63.0
type NewVersionDataFromCborFunc func([]byte) (VersionData, error)
type Protocol ¶
type Protocol struct {
// contains filtered or unexported fields
}
Protocol implements the base functionality of an Ouroboros mini-protocol
func (*Protocol) DoneChan ¶
func (p *Protocol) DoneChan() <-chan struct{}
DoneChan returns the channel used to signal protocol shutdown
func (*Protocol) SendMessage ¶
SendMessage appends a message to the send queue
type ProtocolConfig ¶
type ProtocolConfig struct { Name string ProtocolId uint16 ErrorChan chan error Muxer *muxer.Muxer Mode ProtocolMode Role ProtocolRole MessageHandlerFunc MessageHandlerFunc MessageFromCborFunc MessageFromCborFunc StateMap StateMap StateContext interface{} InitialState State }
ProtocolConfig provides the configuration for Protocol
type ProtocolMode ¶
type ProtocolMode uint
ProtocolMode is an enum of the protocol modes
const ( ProtocolModeNone ProtocolMode = 0 // Default (invalid) protocol mode ProtocolModeNodeToClient ProtocolMode = 1 // Node-to-client protocol mode ProtocolModeNodeToNode ProtocolMode = 2 // Node-to-node protocol mode )
type ProtocolOptions ¶
type ProtocolOptions struct { ConnectionId connection.ConnectionId Muxer *muxer.Muxer ErrorChan chan error Mode ProtocolMode // TODO: remove me Role ProtocolRole Version uint16 }
ProtocolOptions provides common arguments for all mini-protocols
type ProtocolRole ¶
type ProtocolRole uint
ProtocolRole is an enum of the protocol roles
const ( ProtocolRoleNone ProtocolRole = 0 // Default (invalid) protocol role ProtocolRoleClient ProtocolRole = 1 // Client protocol role ProtocolRoleServer ProtocolRole = 2 // Server protocol role )
Protocol roles
type ProtocolStateAgency ¶
type ProtocolStateAgency uint
ProtocolStateAgency is an enum representing the possible protocol state agency values
const ( AgencyNone ProtocolStateAgency = 0 // Default (invalid) value AgencyClient ProtocolStateAgency = 1 // Client agency AgencyServer ProtocolStateAgency = 2 // Server agency )
type ProtocolVersion ¶ added in v0.63.0
type ProtocolVersion struct { NewVersionDataFromCborFunc NewVersionDataFromCborFunc EnableShelleyEra bool EnableAllegraEra bool EnableMaryEra bool EnableAlonzoEra bool EnableBabbageEra bool EnableConwayEra bool // NtC only EnableLocalQueryProtocol bool EnableLocalTxMonitorProtocol bool // NtN only EnableKeepAliveProtocol bool EnableFullDuplex bool EnablePeerSharingProtocol bool PeerSharingUseV11 bool }
func GetProtocolVersion ¶ added in v0.63.0
func GetProtocolVersion(version uint16) ProtocolVersion
GetProtocolVersion returns the protocol version config for the specified protocol version
type ProtocolVersionMap ¶ added in v0.63.0
type ProtocolVersionMap map[uint16]VersionData
func GetProtocolVersionMap ¶ added in v0.63.0
func GetProtocolVersionMap( protocolMode ProtocolMode, networkMagic uint32, diffusionMode bool, peerSharing bool, queryMode bool, ) ProtocolVersionMap
GetProtocolVersionMap returns a data structure suitable for use with the protocol handshake
type State ¶
State represents protocol state with both a numeric ID and a string identifer
type StateMap ¶
type StateMap map[State]StateMapEntry
StateMap represents the state machine definition for a mini-protocol
type StateMapEntry ¶
type StateMapEntry struct { Agency ProtocolStateAgency Transitions []StateTransition Timeout time.Duration }
StateMapEntry represents a protocol state, it's possible state transitions, and an optional timeout
type StateTransition ¶
type StateTransition struct { MsgType uint8 NewState State MatchFunc StateTransitionMatchFunc }
StateTransition represents a protocol state transition
type StateTransitionMatchFunc ¶
StateTransitionMatchFunc represents a function that will take a Message and return a bool that indicates whether the message is a match for the state transition rule
type VersionData ¶ added in v0.63.0
type VersionData interface { NetworkMagic() uint32 //Query() bool // NtN only DiffusionMode() bool PeerSharing() bool }
func NewVersionDataNtC15andUpFromCbor ¶ added in v0.63.0
func NewVersionDataNtC15andUpFromCbor(cborData []byte) (VersionData, error)
func NewVersionDataNtC9to14FromCbor ¶ added in v0.63.0
func NewVersionDataNtC9to14FromCbor(cborData []byte) (VersionData, error)
func NewVersionDataNtN11to12FromCbor ¶ added in v0.63.0
func NewVersionDataNtN11to12FromCbor(cborData []byte) (VersionData, error)
func NewVersionDataNtN13andUpFromCbor ¶ added in v0.63.0
func NewVersionDataNtN13andUpFromCbor(cborData []byte) (VersionData, error)
func NewVersionDataNtN7to10FromCbor ¶ added in v0.63.0
func NewVersionDataNtN7to10FromCbor(cborData []byte) (VersionData, error)
type VersionDataNtC15andUp ¶ added in v0.63.0
type VersionDataNtC15andUp struct { cbor.StructAsArray CborNetworkMagic uint32 CborQuery bool }
func (VersionDataNtC15andUp) DiffusionMode ¶ added in v0.63.0
func (v VersionDataNtC15andUp) DiffusionMode() bool
func (VersionDataNtC15andUp) NetworkMagic ¶ added in v0.63.0
func (v VersionDataNtC15andUp) NetworkMagic() uint32
func (VersionDataNtC15andUp) PeerSharing ¶ added in v0.75.0
func (v VersionDataNtC15andUp) PeerSharing() bool
type VersionDataNtC9to14 ¶ added in v0.63.0
type VersionDataNtC9to14 uint32
func (VersionDataNtC9to14) DiffusionMode ¶ added in v0.63.0
func (v VersionDataNtC9to14) DiffusionMode() bool
func (VersionDataNtC9to14) NetworkMagic ¶ added in v0.63.0
func (v VersionDataNtC9to14) NetworkMagic() uint32
func (VersionDataNtC9to14) PeerSharing ¶ added in v0.75.0
func (v VersionDataNtC9to14) PeerSharing() bool
type VersionDataNtN11to12 ¶ added in v0.63.0
type VersionDataNtN11to12 struct { cbor.StructAsArray CborNetworkMagic uint32 CborInitiatorAndResponderDiffusionMode bool CborPeerSharing uint CborQuery bool }
func (VersionDataNtN11to12) DiffusionMode ¶ added in v0.63.0
func (v VersionDataNtN11to12) DiffusionMode() bool
func (VersionDataNtN11to12) NetworkMagic ¶ added in v0.63.0
func (v VersionDataNtN11to12) NetworkMagic() uint32
func (VersionDataNtN11to12) PeerSharing ¶ added in v0.75.0
func (v VersionDataNtN11to12) PeerSharing() bool
type VersionDataNtN13andUp ¶ added in v0.63.0
type VersionDataNtN13andUp struct {
VersionDataNtN11to12
}
NOTE: the format stays the same, but the values for PeerSharing change
func (VersionDataNtN13andUp) PeerSharing ¶ added in v0.75.0
func (v VersionDataNtN13andUp) PeerSharing() bool
type VersionDataNtN7to10 ¶ added in v0.63.0
type VersionDataNtN7to10 struct { cbor.StructAsArray CborNetworkMagic uint32 CborInitiatorAndResponderDiffusionMode bool }
func (VersionDataNtN7to10) DiffusionMode ¶ added in v0.63.0
func (v VersionDataNtN7to10) DiffusionMode() bool
func (VersionDataNtN7to10) NetworkMagic ¶ added in v0.63.0
func (v VersionDataNtN7to10) NetworkMagic() uint32
func (VersionDataNtN7to10) PeerSharing ¶ added in v0.75.0
func (v VersionDataNtN7to10) PeerSharing() bool
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package chainsync implements the Ouroboros chain-sync protocol
|
Package chainsync implements the Ouroboros chain-sync protocol |
The common package contains types used by multiple mini-protocols
|
The common package contains types used by multiple mini-protocols |
Package handshake implements the Ouroboros handshake protocol
|
Package handshake implements the Ouroboros handshake protocol |
Package localstatequery implements the Ouroboros local-state-query protocol
|
Package localstatequery implements the Ouroboros local-state-query protocol |
Package localtxmonitor implements the Ouroboros local-tx-monitor protocol
|
Package localtxmonitor implements the Ouroboros local-tx-monitor protocol |
Package localtxsubmission implements the Ouroboros local-tx-submission protocol
|
Package localtxsubmission implements the Ouroboros local-tx-submission protocol |
Package peersharing implements the Ouroboros PeerSharing protocol
|
Package peersharing implements the Ouroboros PeerSharing protocol |
Package txsubmission implements the Ouroboros TxSubmission protocol
|
Package txsubmission implements the Ouroboros TxSubmission protocol |