p2p

package
v0.2.5-beta.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2021 License: MIT Imports: 24 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v1.0.0

type Config struct {
	DataDir            string
	LogLevel           log.Level
	GracePeersShutdown time.Duration
	BootstrapTimeout   time.Duration
	MaxMessageSize     int

	DisableNatPort bool     `mapstructure:"disable-natport"`
	Flood          bool     `mapstructure:"flood"`
	Listen         string   `mapstructure:"listen"`
	NetworkID      uint32   `mapstructure:"network-id"`
	Bootnodes      []string `mapstructure:"bootnodes"`
	TargetOutbound int      `mapstructure:"target-outbound"`
	LowPeers       int      `mapstructure:"low-peers"`
	HighPeers      int      `mapstructure:"high-peers"`
}

Config for all things related to p2p layer.

func DefaultConfig added in v1.0.0

func DefaultConfig() Config

DefaultConfig config.

type Host added in v1.0.0

type Host struct {
	host.Host
	*pubsub.PubSub

	*bootstrap.Peers
	// contains filtered or unexported fields
}

Host is a conveniency wrapper for all p2p related functionality required to run a full spacemesh node.

func New

func New(ctx context.Context, logger log.Log, cfg Config, opts ...Opt) (*Host, error)

New initializes libp2p host configured for spacemesh.

func Upgrade added in v1.0.0

func Upgrade(h host.Host, opts ...Opt) (*Host, error)

Upgrade creates Host instance from host.Host.

func (*Host) Stop added in v1.0.0

func (fh *Host) Stop() error

Stop background workers and release external resources.

type Opt added in v1.0.0

type Opt func(fh *Host)

Opt is for configuring Host.

func WithConfig added in v1.0.0

func WithConfig(cfg Config) Opt

WithConfig sets Config for Host.

func WithContext added in v1.0.0

func WithContext(ctx context.Context) Opt

WithContext set context for Host.

func WithLog added in v1.0.0

func WithLog(logger log.Log) Opt

WithLog configures logger for Host.

func WithNodeReporter added in v1.0.0

func WithNodeReporter(reporter func()) Opt

WithNodeReporter updates reporter that is notified every time when node added or removed a peer.

type Peer

type Peer = peer.ID

Peer is an alias to libp2p's peer.ID.

Directories

Path Synopsis
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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