wires

package module
v0.0.0-...-b02d5dc Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2021 License: MIT Imports: 10 Imported by: 1

README

TOPIC-WIRES

A simple topic-based overlay protocol using libp2p.

installation

go get github.com/huiscool/topic-wires

example

see example/example.go

Documentation

Index

Constants

View Source
const (
	TopicWiresProtocolID = protocol.ID("/topic-wires/1.0.0")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type NotifAdapter

type NotifAdapter struct {
	HandleUp   func(neigh peer.ID, topic string)
	HandleDown func(neigh peer.ID, topic string)
}

func (*NotifAdapter) HandleNeighDown

func (na *NotifAdapter) HandleNeighDown(neigh peer.ID, topic string)

func (*NotifAdapter) HandleNeighUp

func (na *NotifAdapter) HandleNeighUp(neigh peer.ID, topic string)

type Notifiee

type Notifiee interface {
	HandleNeighUp(neigh peer.ID, topic string)
	HandleNeighDown(neigh peer.ID, topic string)
}

type PeerSet

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

func NewPeerSet

func NewPeerSet() *PeerSet

func (*PeerSet) Add

func (ps *PeerSet) Add(p peer.ID)

func (*PeerSet) Del

func (ps *PeerSet) Del(p peer.ID)

func (*PeerSet) Equal

func (ps *PeerSet) Equal(another *PeerSet) bool

func (*PeerSet) Slice

func (ps *PeerSet) Slice() []peer.ID

func (*PeerSet) String

func (ps *PeerSet) String() string

type TopicMsgHandler

type TopicMsgHandler func(topic string, from peer.ID, data []byte)

type TopicWires

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

func NewTopicWires

func NewTopicWires(h host.Host) (*TopicWires, error)

func (*TopicWires) Close

func (t *TopicWires) Close() error

func (*TopicWires) Connected

func (t *TopicWires) Connected() []peer.ID

func (*TopicWires) Join

func (t *TopicWires) Join(topic string) error

func (*TopicWires) Leave

func (t *TopicWires) Leave(topic string) error

func (*TopicWires) Neighbors

func (t *TopicWires) Neighbors(topic string) []peer.ID

func (*TopicWires) SendTopicMsg

func (t *TopicWires) SendTopicMsg(topic string, p peer.ID, data []byte) error

func (*TopicWires) SetNotifiee

func (t *TopicWires) SetNotifiee(notifiee Notifiee)

func (*TopicWires) SetTopicMsgHandler

func (t *TopicWires) SetTopicMsgHandler(tmh TopicMsgHandler)

func (*TopicWires) Topics

func (t *TopicWires) Topics() []string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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