p2p

package
v0.0.0-...-fcff443 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2024 License: GPL-3.0 Imports: 6 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(r io.Reader, rpc *RPC) error
}

type DefaultDecoder

type DefaultDecoder struct{}

func (DefaultDecoder) Decode

func (dec DefaultDecoder) Decode(r io.Reader, rpc *RPC) error

type GOBDecoder

type GOBDecoder struct{}

func (GOBDecoder) Decode

func (dec GOBDecoder) Decode(r io.Reader, rpc *RPC) error

type HandshakeFunc

type HandshakeFunc func(peer Peer) error

type Peer

type Peer interface {
	Close() error
}

Peer is an interface that represents the remote node.

func NewTCPPeer

func NewTCPPeer(conn net.Conn, outbound bool) Peer

type RPC

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

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

type TCPTransportOpts

type TCPTransportOpts struct {
	ListenAddr    string
	HandshakeFunc HandshakeFunc
	Decoder
	OnPeer func(peer Peer) error
}

type Transport

type Transport interface {
	ListenAndAccept() error
	Consume() <-chan RPC
}

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

func NewTCPTransport

func NewTCPTransport(opts TCPTransportOpts) Transport

Jump to

Keyboard shortcuts

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