ep2p

package module
v0.0.0-...-840f0fc Latest Latest
Warning

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

Go to latest
Published: May 26, 2023 License: MIT Imports: 15 Imported by: 0

README

go-easy-p2p

go-easy-p2p is a simplified wrapper for go-libp2p.

Dev plan

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Libp2pError

func Libp2pError(err error) error

func TopicAlreadyExistsError

func TopicAlreadyExistsError(topic string) error

func TopicNotFoundError

func TopicNotFoundError(topic string) error

Types

type DHT

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

func (*DHT) Advertise

func (dht *DHT) Advertise(ns string) error

func (*DHT) FindPeers

func (dht *DHT) FindPeers(rendezvous string) (<-chan peer.AddrInfo, error)

type GossipSub

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

func (*GossipSub) Join

func (gs *GossipSub) Join(topic string, opts ...GossipSubOption) (*Topic, error)

func (*GossipSub) Leave

func (gs *GossipSub) Leave(topic string) error

type GossipSubCallback

type GossipSubCallback func(m *pubsub.Message) error

type GossipSubOption

type GossipSubOption func(*Topic) error

func FilterSelf

func FilterSelf(self peer.ID) GossipSubOption

func WithCallback

func WithCallback(callback GossipSubCallback) GossipSubOption

type Host

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

func NewClient

func NewClient(bootstrapPeers []maddr.Multiaddr, logger *zap.Logger) *Host

func NewHost

func NewHost(bootstrapPeers []maddr.Multiaddr, logger *zap.Logger, serverMode bool) *Host

func NewServer

func NewServer(bootstrapPeers []maddr.Multiaddr, logger *zap.Logger) *Host

func (*Host) Desc

func (h *Host) Desc() []string

func (*Host) ID

func (h *Host) ID() peer.ID

func (*Host) Impl

func (h *Host) Impl() host.Host

For testing purposes

func (*Host) NewGossipSub

func (h *Host) NewGossipSub() *GossipSub

func (*Host) Peers

func (h *Host) Peers() []peer.ID

func (*Host) Send

func (h *Host) Send(data []byte, peer peer.ID) error

func (*Host) SetDefaultRecvHandler

func (h *Host) SetDefaultRecvHandler(callback func(network.Stream))

type Topic

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

func (*Topic) Publish

func (t *Topic) Publish(data []byte) error

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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