p2pnode

package
Version: v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2020 License: Apache-2.0 Imports: 18 Imported by: 9

Documentation

Overview

Copyright 2020 PhysarumSM Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

View Source
const (
	MaxConnAttempts = 5

	// 512 seconds = 8 mins 32 secs
	MaxBackoffSecs = 512
)

Variables

This section is empty.

Functions

func ReconnectCB

func ReconnectCB(node *Node, cfg *Config) func(network.Network, network.Conn)

Returns a callback function for peer disconnection events

Given the Node and the original Config used to create it, always try to maintain its connectivity to the original bootstraps (i.e. reconnect to them if they are disconnected. Upon reconnection, re-advertise any services and/or content.

Types

type Config

type Config struct {
	PrivKey            crypto.PrivKey
	ListenAddrs        []string
	BootstrapPeers     []multiaddr.Multiaddr
	StreamHandlers     []network.StreamHandler
	HandlerProtocolIDs []protocol.ID
	Rendezvous         []string
	PSK                pnet.PSK
}

Config is a structure for passing arguments into Node constructor NewNode

func NewConfig

func NewConfig() Config

Config constructor that returns default configuration

type Node

type Node struct {
	Ctx              context.Context
	Close            context.CancelFunc
	Host             host.Host
	DHT              *dht.IpfsDHT
	RoutingDiscovery *discovery.RoutingDiscovery
	NetworkCallbacks *network.NotifyBundle
}

Node is a struct that holds all libp2p related objects for a node instance

func NewNode

func NewNode(ctx context.Context, config Config) (Node, error)

Node constructor

func (*Node) Advertise

func (node *Node) Advertise(rendezvous string) error

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL