Documentation ¶
Index ¶
- Variables
- type DHT
- type MDNS
- type Options
- type P2P
- func (p *P2P) AllConnectedPeers() p2peer.IDSlice
- func (p *P2P) ConnectedProctectedPeersNickList() []string
- func (p *P2P) ConnectedProtectedPeers() p2peer.IDSlice
- func (p *P2P) ConnectedProtectedPeersAddrInfo() map[string]p2peer.AddrInfo
- func (p *P2P) ConnectedUnprotectedPeers() p2peer.IDSlice
- func (p *P2P) StartDiscoveryLoop(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
var (
ErrFailedToCreateRoutingDiscovery = fmt.Errorf("failed to create routing discovery")
)
Functions ¶
This section is empty.
Types ¶
type Options ¶ added in v0.4.0
func DefaultOptions ¶ added in v0.4.0
func DefaultOptions() Options
type P2P ¶ added in v0.0.2
type P2P struct { PubSub *p2ppubsub.PubSub DHT *DHT MDNS *MDNS Host host.Host AddrInfo p2peer.AddrInfo }
This is not a normal libp2p node, it's a wrapper around it. And it is specific to this project. It contains a libp2p node, a pubsub service and a DHT instance. It also contains a list of connected peers.
func Init ¶
Initialise everything needed for p2p communication. The function forces use of a specific IPNS key. Taken from the config package. It would be an error to initialise the node with a different key. The input is derived from Config() in the config package.
func (*P2P) AllConnectedPeers ¶ added in v0.3.0
AllConnectedPeers returns a slice of p2peer.ID for all connected peers of the given host.
func (*P2P) ConnectedProctectedPeersNickList ¶ added in v0.3.0
func (*P2P) ConnectedProtectedPeers ¶ added in v0.3.0
ConnectedProtectedPeers returns a slice of p2peer.ID for all protected connected peers.
func (*P2P) ConnectedProtectedPeersAddrInfo ¶ added in v0.3.0
ConnectedProtectedPeersAddrInfo returns a map of p2peer.ID to AddrInfo for all protected connected peers.
func (*P2P) ConnectedUnprotectedPeers ¶ added in v0.3.0
ConnectedUnprotectedPeers returns a slice of p2peer.ID for all unprotected connected peers.