Documentation
¶
Overview ¶
Package handshake implements the Ouroboros handshake protocol
Index ¶
- Constants
- Variables
- func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error)
- type Client
- type Config
- type FinishedFunc
- type Handshake
- type HandshakeOptionFunc
- func WithClientFullDuplex(fullDuplex bool) HandshakeOptionFunc
- func WithFinishedFunc(finishedFunc FinishedFunc) HandshakeOptionFunc
- func WithNetworkMagic(networkMagic uint32) HandshakeOptionFunc
- func WithProtocolVersions(versions []uint16) HandshakeOptionFunc
- func WithTimeout(timeout time.Duration) HandshakeOptionFunc
- type MsgAcceptVersion
- type MsgProposeVersions
- type MsgRefuse
- type Server
Constants ¶
const ( DiffusionModeInitiatorOnly = false DiffusionModeInitiatorAndResponder = true )
Diffusion modes
const ( MessageTypeProposeVersions = 0 MessageTypeAcceptVersion = 1 MessageTypeRefuse = 2 )
Message types
const ( RefuseReasonVersionMismatch = 0 RefuseReasonDecodeError = 1 RefuseReasonRefused = 2 )
Refusal reasons
Variables ¶
var StateMap = protocol.StateMap{ // contains filtered or unexported fields }
Handshake protocol state machine
Functions ¶
Types ¶
type Client ¶
Client implements the Handshake client
type Config ¶
type Config struct {
ProtocolVersions []uint16
NetworkMagic uint32
ClientFullDuplex bool
FinishedFunc FinishedFunc
Timeout time.Duration
}
Config is used to configure the Handshake protocol instance
func NewConfig ¶
func NewConfig(options ...HandshakeOptionFunc) Config
NewConfig returns a new Handshake config object with the provided options
type HandshakeOptionFunc ¶
type HandshakeOptionFunc func(*Config)
HandshakeOptionFunc represents a function used to modify the Handshake protocol config
func WithClientFullDuplex ¶
func WithClientFullDuplex(fullDuplex bool) HandshakeOptionFunc
WithClientFullDuplex specifies whether to request full duplex mode when acting as a client
func WithFinishedFunc ¶
func WithFinishedFunc(finishedFunc FinishedFunc) HandshakeOptionFunc
WithFinishedFunc specifies the Finished callback function
func WithNetworkMagic ¶
func WithNetworkMagic(networkMagic uint32) HandshakeOptionFunc
WithNetworkMagic specifies the network magic value
func WithProtocolVersions ¶
func WithProtocolVersions(versions []uint16) HandshakeOptionFunc
WithProtocolVersions specifies the supported protocol versions
func WithTimeout ¶
func WithTimeout(timeout time.Duration) HandshakeOptionFunc
WithTimeout specifies the timeout for the handshake operation
type MsgAcceptVersion ¶
type MsgAcceptVersion struct {
protocol.MessageBase
Version uint16
VersionData interface{}
}
func NewMsgAcceptVersion ¶
func NewMsgAcceptVersion(version uint16, versionData interface{}) *MsgAcceptVersion
type MsgProposeVersions ¶
type MsgProposeVersions struct {
protocol.MessageBase
VersionMap map[uint16]interface{}
}
func NewMsgProposeVersions ¶
func NewMsgProposeVersions(versionMap map[uint16]interface{}) *MsgProposeVersions
type MsgRefuse ¶
type MsgRefuse struct {
protocol.MessageBase
Reason []interface{}
}
func NewMsgRefuse ¶
func NewMsgRefuse(reason []interface{}) *MsgRefuse