p2p

package
v0.0.0-...-29ced8b Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NOPHandshakeFunc

func NOPHandshakeFunc(Peer) error

Types

type Decoder

type Decoder interface {
	Decode(io.Reader, *Message) error
}

type DefaultDecoder

type DefaultDecoder struct{}

func (DefaultDecoder) Decode

func (nd DefaultDecoder) Decode(r io.Reader, msg *Message) error

type GOBDecoder

type GOBDecoder struct {
}

func (GOBDecoder) Decode

func (gd GOBDecoder) Decode(r io.Reader, msg *Message) error

type HandshakeFunc

type HandshakeFunc func(Peer) error

HandshakeFunc... ?

type Message

type Message struct {
	From    net.Addr
	Payload []byte
}

Message holds any arbitrary data that is being sent over the each transport between two nodes in the network.

type Peer

type Peer interface {
}

Peer is an interface that represent the remote node.

type TCPPeer

type TCPPeer struct {
	// contains filtered or unexported fields
}

TCPPeer represent the remote node over a TCP established connection.

func NewTCPPeer

func NewTCPPeer(conn net.Conn, outbound bool) *TCPPeer

type TCPTransport

type TCPTransport struct {
	TCPTransportOpts
	// contains filtered or unexported fields
}

func NewTCPTransport

func NewTCPTransport(opts TCPTransportOpts) *TCPTransport

func (*TCPTransport) ListenAndAccept

func (t *TCPTransport) ListenAndAccept() error

type TCPTransportOpts

type TCPTransportOpts struct {
	ListenAddr    string
	HandshakeFunc HandshakeFunc
	Decoder       Decoder
}

type Transport

type Transport interface {
	ListenAndAccept() error
}

Transport is anything that handles the communication between the nodes in the network. This can be of the form (TCP, UDP, websockets, etc)

Jump to

Keyboard shortcuts

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