p2pkeswarm

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: 16 Imported by: 1

Documentation

Index

Constants

View Source
const Overhead = p2pke.Overhead

Variables

This section is empty.

Functions

func DefaultFingerprinter

func DefaultFingerprinter(pub *x509.PublicKey) (ret p2p.PeerID)

DefaultFingerprinter returns a fingerprint for pub using SHAKE256

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]) GetPeerID

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

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() p2p.Addr

type Fingerprinter

type Fingerprinter = func(*x509.PublicKey) p2p.PeerID

type Option

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

func WithBackground

func WithBackground[T p2p.Addr](ctx context.Context) Option[T]

WithBackground sets the background context used by the swarm

func WithFingerprinter

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

WithFingerprinter sets the fingerprinter used by the swarm. The default is p2p.DefaultFingerprinter

func WithWhitelist

func WithWhitelist[T p2p.Addr](fn func(Addr[T]) bool) Option[T]

WithWhitelist sets the whitelist for incoming messages. If !fn(msg.Src) then the message is dropped.

type Swarm

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

func New

func New[T p2p.Addr](inner p2p.Swarm[T], privateKey x509.PrivateKey, opts ...Option[T]) *Swarm[T]

func (*Swarm[T]) Close

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

func (*Swarm[T]) LocalAddrs

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

LocalAddrs implements p2p.Swarm.LocalAddrs

func (*Swarm[T]) LookupPublicKey

func (s *Swarm[T]) LookupPublicKey(ctx context.Context, dst Addr[T]) (ret x509.PublicKey, _ error)

LookupPublicKey implements p2p.SecureSwarm.PublicKey

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() x509.PublicKey

PublicKey implements p2p.SecureSwarm.PublicKey

func (*Swarm[T]) Receive

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

Receive implements p2p.Swarm.Receive

func (*Swarm[T]) Tell

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

Tell implements p2p.Swarm.Tell

Jump to

Keyboard shortcuts

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