libp2p

package
v1.999.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: GPL-3.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ListenAddrWithIp4AndTcp defines the listening address with ip v.4 and TCP
	ListenAddrWithIp4AndTcp = "/ip4/0.0.0.0/tcp/"

	// ListenLocalhostAddrWithIp4AndTcp defines the local host listening ip v.4 address and TCP
	ListenLocalhostAddrWithIp4AndTcp = "/ip4/127.0.0.1/tcp/"

	// DirectSendID represents the protocol ID for sending and receiving direct P2P messages
	DirectSendID = protocol.ID("/erd/directsend/1.0.0")
)

Variables

This section is empty.

Functions

func NewConnectableHost

func NewConnectableHost(h host.Host) *connectableHost

NewConnectableHost creates a new connectable host implementation

func NewDirectSender

func NewDirectSender(
	ctx context.Context,
	h host.Host,
	messageHandler func(msg *pubsub.Message, fromConnectedPeer core.PeerID) error,
) (*directSender, error)

NewDirectSender returns a new instance of direct sender object

func NewMessage

func NewMessage(msg *pubsub.Message, marshalizer p2p.Marshalizer) (*message.Message, error)

NewMessage returns a new instance of a Message object

func NewMockMessenger

func NewMockMessenger(
	args ArgsNetworkMessenger,
	mockNet mocknet.Mocknet,
) (*networkMessenger, error)

NewMockMessenger creates a new sandbox testable instance of libP2P messenger It should not open ports on current machine Should be used only in testing!

func NewNetworkMessenger

func NewNetworkMessenger(args ArgsNetworkMessenger) (*networkMessenger, error)

NewNetworkMessenger creates a libP2P messenger by opening a port on the current machine

Types

type ArgsNetworkMessenger

type ArgsNetworkMessenger struct {
	ListenAddress         string
	Marshalizer           p2p.Marshalizer
	P2pConfig             config.P2PConfig
	SyncTimer             p2p.SyncTimer
	PreferredPeersHolder  p2p.PreferredPeersHolderHandler
	NodeOperationMode     p2p.NodeOperation
	PeersRatingHandler    p2p.PeersRatingHandler
	ConnectionWatcherType string
}

ArgsNetworkMessenger defines the options used to create a p2p wrapper

type ConnectableHost

type ConnectableHost interface {
	host.Host
	ConnectToPeer(ctx context.Context, address string) error
	AddressToPeerInfo(address string) (*peer.AddrInfo, error)
	IsInterfaceNil() bool
}

ConnectableHost is an enhanced Host interface that has the ability to connect to a string address

type ConnectionMonitor

type ConnectionMonitor interface {
	network.Notifiee
	IsConnectedToTheNetwork(netw network.Network) bool
	SetThresholdMinConnectedPeers(thresholdMinConnectedPeers int, netw network.Network)
	ThresholdMinConnectedPeers() int
	Close() error
	IsInterfaceNil() bool
}

ConnectionMonitor defines the behavior of a connection monitor

type LocalSyncTimer

type LocalSyncTimer struct {
}

LocalSyncTimer uses the local system to provide the current time

func (*LocalSyncTimer) CurrentTime

func (lst *LocalSyncTimer) CurrentTime() time.Time

CurrentTime returns the local current time

func (*LocalSyncTimer) IsInterfaceNil

func (lst *LocalSyncTimer) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

type MutexHolder

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

MutexHolder holds a cache of mutexes: pairs of (key, *sync.Mutex)

func NewMutexHolder

func NewMutexHolder(mutexesCapacity int) (*MutexHolder, error)

NewMutexHolder creates a new instance of MutexHolder with specified capacity.

func (*MutexHolder) Get

func (mh *MutexHolder) Get(key string) *sync.Mutex

Get returns a mutex for the provided key. If the key was not found, it will create a new mutex, save it in the cache and returns it.

type PeerDiscovererWithSharder

type PeerDiscovererWithSharder interface {
	p2p.PeerDiscoverer
	SetSharder(sharder p2p.Sharder) error
}

PeerDiscovererWithSharder extends the PeerDiscoverer with the possibility to set the sharder

type PeerInfoHandler

type PeerInfoHandler func(pInfo peer.AddrInfo)

PeerInfoHandler is the signature of the handler that gets called whenever an action for a peerInfo is triggered

Jump to

Keyboard shortcuts

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