sprawl: github.com/sprawl/sprawl/p2p Index | Files

package p2p

import "github.com/sprawl/sprawl/p2p"

Index

Package Files

options.go p2p.go

type P2p Uses

type P2p struct {
    Logger interfaces.Logger
    Config interfaces.Config

    Orders   interfaces.OrderService
    Channels interfaces.ChannelService
    // contains filtered or unexported fields
}

P2p stores all things required to converse with other peers in the Sprawl network and save data locally

func NewP2p Uses

func NewP2p(log interfaces.Logger, config interfaces.Config, privateKey crypto.PrivKey, publicKey crypto.PubKey) (p2p *P2p)

NewP2p returns a P2p struct with an input channel

func (*P2p) Close Uses

func (p2p *P2p) Close()

Close closes the underlying libp2p host

func (*P2p) CreateOptions Uses

func (p2p *P2p) CreateOptions() []libp2pConfig.Option

CreateOptions queries p2p.Config for any user-submitted options and assigns defaults

func (*P2p) RegisterChannelService Uses

func (p2p *P2p) RegisterChannelService(channels interfaces.ChannelService)

RegisterChannelService registers a channel service to persist joined channels locally

func (*P2p) RegisterOrderService Uses

func (p2p *P2p) RegisterOrderService(orders interfaces.OrderService)

RegisterOrderService registers an order service to persist order data locally

func (*P2p) Run Uses

func (p2p *P2p) Run()

Run runs the p2p network

func (*P2p) Send Uses

func (p2p *P2p) Send(message *pb.WireMessage)

Send queues a message for sending to other peers

func (*P2p) Subscribe Uses

func (p2p *P2p) Subscribe(channel *pb.Channel)

Subscribe subscribes to a libp2p pubsub channel defined with "channel"

func (*P2p) Unsubscribe Uses

func (p2p *P2p) Unsubscribe(channel *pb.Channel)

Unsubscribe sends a quit signal to a channel goroutine

Package p2p imports 18 packages (graph) and is imported by 1 packages. Updated 2019-12-15. Refresh now. Tools for package owners.