peer

package
v0.0.0-...-6d5efb9 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Libp2pOptionsExtra = []libp2p.Option{
	libp2p.NATPortMap(),
	libp2p.ConnectionManager(connMgr),
	libp2p.EnableNATService(),
}

Functions

func GenerateSwarmKey

func GenerateSwarmKey() string

func SetupLibp2p

func SetupLibp2p(
	ctx context.Context,
	hostKey crypto.PrivKey,
	secret pnet.PSK,
	listenAddrs []multiaddr.Multiaddr,
	ds datastore.Batching,
	opts ...libp2p.Option,
) (host.Host, *dht.IpfsDHT, error)

Types

type Config

type Config struct {
	Offline bool
	// ReprovideInterval sets how often to reprovide records to the DHT
	ReprovideInterval time.Duration
	// Disables wrapping the blockstore in an ARC cache + Bloomfilter. Use
	// when the given blockstore or datastore already has caching, or when
	// caching is not needed.
	UncachedBlockstore bool

	TopicHandler func(*proto.UpdatePeer)
}

Config wraps configuration options for the Peer.

type Peer

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

func New

func New(
	ctx context.Context,
	datastore datastore.Batching,
	host host.Host,
	dht routing.Routing,
	cfg *Config,
) *Peer

func (*Peer) Bootstrap

func (p *Peer) Bootstrap(peers []peer.AddrInfo)

Bootstrap is an optional helper to connect to the given peers and bootstrap21 the Peer DHT (and Bitswap). This is a best-effort function. Errors are only logged and a warning is printed when less than half of the given peers could be contacted. It is fine to pass a list where some peers will not be reachable.

func (*Peer) Discover

func (p *Peer) Discover(rendezvous string)

func (*Peer) HostAddr

func (p *Peer) HostAddr() string

func (*Peer) ID

func (p *Peer) ID() string

func (*Peer) NewStream

func (p *Peer) NewStream(proto, target string) (coreNetwork.Stream, error)

func (*Peer) Publish

func (p *Peer) Publish(ctx context.Context, data []byte) error

func (*Peer) RoutedHost

func (p *Peer) RoutedHost() host.Host

Jump to

Keyboard shortcuts

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