p2p

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DiscoveryInterval is the time between mdns queries.
	DiscoveryInterval = time.Duration(15) * time.Second
	// DiscoveryConnectTimeout is the time to wait for a connection to be made.
	DiscoveryConnectTimeout = time.Second * 30
	// DiscoveryServiceTag is used to identify a group of nodes.
	DiscoveryServiceTag = discovery.ServiceTag
)
View Source
const (
	// LowWater is the minimum amount of connections to keep.
	LowWater = 100
	// HighWater is the maximum amount of connections to keep.
	HighWater = 400
	// GracePeriod is how long wait to consider a connection active.
	GracePeriod = time.Minute
)
View Source
const (
	// ReprovideInterval is the time between reprovides.
	ReprovideInterval = 12 * time.Hour
	// QueueName is the name for the provider queue.
	QueueName = "repro"
)
View Source
const DefaultKeyType = crypto.Ed25519

DefaultKeyType is the default private key type.

Variables

This section is empty.

Functions

func Bootstrap

func Bootstrap(ctx context.Context, host host.Host, router routing.Routing) error

Bootstrap initiates connections to a list of known peers.

func DecodeKey

func DecodeKey(encoded string) (crypto.PrivKey, error)

DecodeKey returns a key from a base64 encoded version.

func Discovery

func Discovery(ctx context.Context, h host.Host) error

Discovery starts discovering peers through mdns.

func EncodeKey

func EncodeKey(priv crypto.PrivKey) (string, error)

EncodeKey returns a base64 encoded version of the key.

func GenerateKey

func GenerateKey() (crypto.PrivKey, error)

GenerateKey returns a new private key.

func NewHost

func NewHost(ctx context.Context, priv crypto.PrivKey, listenAddr []string) (host.Host, routing.Routing, error)

NewHost returns a new libp2p host and router.

Types

type Peer

type Peer struct {
	// Blocks is the ipfs blockstore.
	Blocks blockstore.Blockstore
	// DAG implements ipld DAGService.
	DAG ipld.DAGService
	// Host is the libp2p host.
	Host host.Host
	// Router is the libp2p router.
	Router routing.Routing
}

Peer implements p2p services.

func NewPeer

func NewPeer(ctx context.Context, host host.Host, router routing.Routing, dstore datastore.Batching) (*Peer, error)

New returns a new peer using the given host, router, and datstore.

Jump to

Keyboard shortcuts

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