peersharing

package
v0.55.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Overview

Package handshake implements the Ouroboros handshake protocol

Index

Constants

View Source
const (
	MessageTypeShareRequest = 0
	MessageTypeSharePeers   = 1
	MessageTypeDone         = 2
)

Message types

View Source
const (
	ProtocolName = "peer-sharing"
	ProtocolId   = 10
)

Protocol identifiers

Variables

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

PeerSharing protocol state machine

Functions

func NewMsgFromCbor

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

NewMsgFromCbor parses a PeerSharing message from CBOR

Types

type Client

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

Client implements the PeerSharing client

func NewClient

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

NewClient returns a new PeerSharing client object

func (*Client) GetPeers

func (c *Client) GetPeers(amount uint8) ([]interface{}, error)

type Config

type Config struct {
	Timeout time.Duration
}

Config is used to configure the PeerSharing protocol instance

func NewConfig

func NewConfig(options ...PeerSharingOptionFunc) Config

NewConfig returns a new PeerSharing config object with the provided options

type MsgDone

type MsgDone struct {
	protocol.MessageBase
}

func NewMsgDone

func NewMsgDone() *MsgDone

type MsgSharePeers

type MsgSharePeers struct {
	protocol.MessageBase
	// TODO: parse peer addresses
	/*
		peerAddress = [0, word32, portNumber]
		      ; ipv6 + portNumber
		    / [1, word32, word32, word32, word32, flowInfo, scopeId, portNumber]

		portNumber = word16

		flowInfo = word32
		scopeId = word32
	*/
	PeerAddresses []interface{}
}

func NewMsgSharePeers

func NewMsgSharePeers(peerAddresses []interface{}) *MsgSharePeers

type MsgShareRequest

type MsgShareRequest struct {
	protocol.MessageBase
	Amount uint8
}

func NewMsgShareRequest

func NewMsgShareRequest(amount uint8) *MsgShareRequest

type PeerSharing

type PeerSharing struct {
	Client *Client
	Server *Server
}

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

func New

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

New returns a new PeerSharing object

type PeerSharingOptionFunc

type PeerSharingOptionFunc func(*Config)

PeerSharingOptionFunc represents a function used to modify the PeerSharing protocol config

func WithTimeout

func WithTimeout(timeout time.Duration) PeerSharingOptionFunc

WithTimeout specifies the timeout for the handshake operation

type Server

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

Server implements the PeerSharing server

func NewServer

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

NewServer returns a new PeerSharing server object

Jump to

Keyboard shortcuts

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