handshake

package
v0.69.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2023 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Overview

Package handshake implements the Ouroboros handshake protocol

Index

Constants

View Source
const (
	ProtocolName = "handshake"
	ProtocolId   = 0
)

Protocol identifiers

View Source
const (
	MessageTypeProposeVersions = 0
	MessageTypeAcceptVersion   = 1
	MessageTypeRefuse          = 2
)

Message types

View Source
const (
	RefuseReasonVersionMismatch = 0
	RefuseReasonDecodeError     = 1
	RefuseReasonRefused         = 2
)

Refusal reasons

Variables

View Source
var StateMap = protocol.StateMap{
	// contains filtered or unexported fields
}

Handshake protocol state machine

Functions

func NewMsgFromCbor

func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error)

NewMsgFromCbor parses a Handshake message from CBOR

Types

type Client

type Client struct {
	*protocol.Protocol
	// contains filtered or unexported fields
}

Client implements the Handshake client

func NewClient

func NewClient(protoOptions protocol.ProtocolOptions, cfg *Config) *Client

NewClient returns a new Handshake client object

func (*Client) Start

func (c *Client) Start()

Start begins the handshake process

type Config

type Config struct {
	ProtocolVersionMap protocol.ProtocolVersionMap
	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 FinishedFunc

type FinishedFunc func(uint16, protocol.VersionData) error

Callback function types

type Handshake

type Handshake struct {
	Client *Client
	Server *Server
}

Handshake is a wrapper object that holds the client and server instances

func New

func New(protoOptions protocol.ProtocolOptions, cfg *Config) *Handshake

New returns a new Handshake object

type HandshakeOptionFunc

type HandshakeOptionFunc func(*Config)

HandshakeOptionFunc represents a function used to modify the Handshake protocol config

func WithFinishedFunc

func WithFinishedFunc(finishedFunc FinishedFunc) HandshakeOptionFunc

WithFinishedFunc specifies the Finished callback function

func WithProtocolVersionMap added in v0.63.0

func WithProtocolVersionMap(versionMap protocol.ProtocolVersionMap) HandshakeOptionFunc

WithProtocolVersionMap 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 cbor.RawMessage
}

func NewMsgAcceptVersion

func NewMsgAcceptVersion(
	version uint16,
	versionData protocol.VersionData,
) *MsgAcceptVersion

type MsgProposeVersions

type MsgProposeVersions struct {
	protocol.MessageBase
	VersionMap map[uint16]cbor.RawMessage
}

func NewMsgProposeVersions

func NewMsgProposeVersions(
	versionMap protocol.ProtocolVersionMap,
) *MsgProposeVersions

type MsgRefuse

type MsgRefuse struct {
	protocol.MessageBase
	Reason []interface{}
}

func NewMsgRefuse

func NewMsgRefuse(reason []interface{}) *MsgRefuse

type Server

type Server struct {
	*protocol.Protocol
	// contains filtered or unexported fields
}

Server implements the Handshake server

func NewServer

func NewServer(protoOptions protocol.ProtocolOptions, cfg *Config) *Server

NewServer returns a new Handshake server object

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL