p2p

package
v0.0.0-...-e5f450f Latest Latest
Warning

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

Go to latest
Published: May 1, 2022 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddrsFactory

func AddrsFactory(announce []string, noAnnounce []string) func() (_ p2pconfig.AddrsFactory, err error)

AddrsFactory returns a constructor for AddrsFactory.

func Components

func Components(cfg Config) fx.Option

Components collects all the components and services related to p2p.

func ConnectionGater

func ConnectionGater(ds datastore.Batching) (coreconnmgr.ConnectionGater, error)

ConnectionGater constructs a ConnectionGater.

func ConnectionManager

func ConnectionManager(cfg Config) func() (coreconnmgr.ConnManager, error)

ConnectionManager provides a constructor for ConnectionManager.

func ContentRouting

func ContentRouting(router routing.PeerRouting) routing.ContentRouting

func DAG

DAG constructs IPFS's DAG Service for fetching arbitrary Merkle structures.

func DataExchange

func DataExchange(cfg Config) func(bitSwapParams) (exchange.Interface, blockstore.Blockstore, error)

DataExchange provides a constructor for IPFS block's DataExchange over BitSwap.

func Host

func Host(cfg Config) func(hostParams) (HostBase, error)

Host returns constructor for Host.

func ID

func ID(key crypto.PrivKey, pstore peerstore.Peerstore) (peer.ID, error)

func Key

func Key(kstore keystore.Keystore) (crypto.PrivKey, error)

Key provides a networking private key and PeerID of the node.

func Listen

func Listen(listen []string) func(host host.Host) (err error)

Listen returns invoke function that starts listening for inbound connections with libp2p.Host.

func PeerRouting

func PeerRouting(cfg Config) func(routingParams) (routing.PeerRouting, error)

PeerRouting provides constructor for PeerRouting over DHT. Basically, this provides a way to discover peer addresses by respecting public keys.

func PeerStore

func PeerStore() (peerstore.Peerstore, error)

PeerStore constructs a PeerStore.

func PubSub

func PubSub(cfg Config) func(pubSubParams) (*pubsub.PubSub, error)

PubSub provides a constructor for PubSub protocol with GossipSub routing.

func RoutedHost

func RoutedHost(base HostBase, r routing.PeerRouting) host.Host

RoutedHost constructs a wrapped Host that may fallback to address discovery, if any top-level operation on the Host is provided with PeerID(Hash(PbK)) only.

func WithLifecycle

func WithLifecycle(ctx context.Context, lc fx.Lifecycle) context.Context

WithLifecycle wraps a context to be canceled when the lifecycle stops.

Types

type Config

type Config struct {
	// ListenAddresses - Addresses to listen to on local NIC.
	ListenAddresses []string
	// AnnounceAddresses - Addresses to be announced/advertised for peers to connect to
	AnnounceAddresses []string
	// NoAnnounceAddresses - Addresses the P2P subsystem may know about, but that should not be announced/advertised,
	// as undialable from WAN
	NoAnnounceAddresses []string
	// Bootstrapper is flag telling this node is a bootstrapper.
	Bootstrapper bool
	// ConnManager is a configuration tuple for ConnectionManager.
	ConnManager ConnManagerConfig
}

Config combines all configuration fields for P2P subsystem.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns default configuration for P2P subsystem.

type ConnManagerConfig

type ConnManagerConfig struct {
	// Low and High are watermarks governing the number of connections that'll be maintained.
	Low, High int
	// GracePeriod is the amount of time a newly opened connection is given before it becomes subject to pruning.
	GracePeriod time.Duration
}

ConnManagerConfig configures connection manager.

func DefaultConnManagerConfig

func DefaultConnManagerConfig() ConnManagerConfig

DefaultConnManagerConfig returns defaults for ConnManagerConfig.

type HostBase

type HostBase host.Host

Jump to

Keyboard shortcuts

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