quicswarm

package
v0.0.0-...-d4b7e32 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2023 License: MPL-2.0 Imports: 22 Imported by: 2

Documentation

Index

Constants

View Source
const DefaultMTU = 1 << 20

Variables

This section is empty.

Functions

func DefaultFingerprinter

func DefaultFingerprinter(x PublicKey) p2p.PeerID

Types

type Addr

type Addr[T p2p.Addr] struct {
	ID   p2p.PeerID
	Addr T
}

func ParseAddr

func ParseAddr[T p2p.Addr](inner p2p.AddrParser[T], data []byte) (Addr[T], error)

func (Addr[T]) Equals

func (a Addr[T]) Equals(b Addr[T]) bool

func (Addr[T]) GetPeerID

func (a Addr[T]) GetPeerID() p2p.PeerID

func (Addr[T]) Key

func (a Addr[T]) Key() string

func (Addr[T]) Map

func (a Addr[T]) Map(fn func(T) T) Addr[T]

func (Addr[T]) MarshalText

func (a Addr[T]) MarshalText() ([]byte, error)

func (Addr[T]) String

func (a Addr[T]) String() string

func (Addr[T]) Unwrap

func (a Addr[T]) Unwrap() T

type Fingerprinter

type Fingerprinter = func(PublicKey) p2p.PeerID

type Option

type Option[T p2p.Addr] func(s *Swarm[T])

func WithFingerprinter

func WithFingerprinter[T p2p.Addr](fp Fingerprinter) Option[T]

func WithMTU

func WithMTU[T p2p.Addr](x int) Option[T]

WithMTU sets the swarm's MTU, if not set it will default to DefaultMTU

func WithWhilelist

func WithWhilelist[T p2p.Addr](f func(p2p.Addr) bool) Option[T]

type PrivateKey

type PrivateKey = x509.PrivateKey

type PublicKey

type PublicKey = x509.PublicKey

type Swarm

type Swarm[T p2p.Addr] struct {
	// contains filtered or unexported fields
}

func New

func New[T p2p.Addr](x p2p.Swarm[T], privKey x509.PrivateKey, opts ...Option[T]) (*Swarm[T], error)

New creates a new swarm on top of x, using privKey for authentication

func NewOnUDP

func NewOnUDP(laddr string, privKey x509.PrivateKey, opts ...Option[udpswarm.Addr]) (*Swarm[udpswarm.Addr], error)

func (*Swarm[T]) Ask

func (s *Swarm[T]) Ask(ctx context.Context, resp []byte, dst Addr[T], data p2p.IOVec) (int, error)

func (*Swarm[T]) Close

func (s *Swarm[T]) Close() (retErr error)

func (*Swarm[T]) LocalAddrs

func (s *Swarm[T]) LocalAddrs() (ret []Addr[T])

func (*Swarm[T]) LocalID

func (s *Swarm[T]) LocalID() p2p.PeerID

func (*Swarm[T]) LookupPublicKey

func (s *Swarm[T]) LookupPublicKey(ctx context.Context, x Addr[T]) (PublicKey, error)

func (*Swarm[T]) MTU

func (s *Swarm[T]) MTU() int

func (*Swarm[T]) ParseAddr

func (s *Swarm[T]) ParseAddr(data []byte) (Addr[T], error)

func (*Swarm[T]) PublicKey

func (s *Swarm[T]) PublicKey() PublicKey

func (*Swarm[T]) Receive

func (s *Swarm[T]) Receive(ctx context.Context, th func(p2p.Message[Addr[T]])) error

func (*Swarm[T]) ServeAsk

func (s *Swarm[T]) ServeAsk(ctx context.Context, fn func(context.Context, []byte, p2p.Message[Addr[T]]) int) error

func (*Swarm[T]) Tell

func (s *Swarm[T]) Tell(ctx context.Context, dst Addr[T], data p2p.IOVec) error

Jump to

Keyboard shortcuts

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