Documentation ¶
Index ¶
- Constants
- Variables
- func NewConnectableHost(h host.Host) *connectableHost
- func NewDirectSender(ctx context.Context, h host.Host, ...) (*directSender, error)
- func NewMemoryMessenger(ctx context.Context, mockNet mocknet.Mocknet, ...) (*networkMessenger, error)
- func NewNetworkMessenger(ctx context.Context, port int, p2pPrivKey libp2pCrypto.PrivKey, ...) (*networkMessenger, error)
- func NewNetworkMessengerOnFreePort(ctx context.Context, p2pPrivKey libp2pCrypto.PrivKey, ...) (*networkMessenger, error)
- type ConnectableHost
- type Libp2pContext
- type Message
- type MutexHolder
- type PeerInfoHandler
Constants ¶
const DirectSendID = protocol.ID("/directsend/1.0.0")
DirectSendID represents the protocol ID for sending and receiving direct P2P messages
const ListenAddrWithIp4AndTcp = "/ip4/0.0.0.0/tcp/"
ListenAddrWithIp4AndTcp defines the listening address with ip v.4 and TCP
const ListenLocalhostAddrWithIp4AndTcp = "/ip4/127.0.0.1/tcp/"
ListenLocalhostAddrWithIp4AndTcp defines the local host listening ip v.4 address and TCP
Variables ¶
var DurationBetweenReconnectAttempts = time.Second * 5
DurationBetweenReconnectAttempts is used as to not call reconnecter.ReconnectToNetwork() to often when there are a lot of peers disconnecting and reconnection to initial nodes succeed
Functions ¶
func NewConnectableHost ¶
NewConnectableHost creates a new connectable host implementation
func NewDirectSender ¶
func NewDirectSender( ctx context.Context, h host.Host, messageHandler func(msg p2p.MessageP2P) error, ) (*directSender, error)
NewDirectSender returns a new instance of direct sender object
func NewMemoryMessenger ¶ added in v1.0.3
func NewMemoryMessenger( ctx context.Context, mockNet mocknet.Mocknet, peerDiscoverer p2p.PeerDiscoverer) (*networkMessenger, error)
NewMemoryMessenger 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( ctx context.Context, port int, p2pPrivKey libp2pCrypto.PrivKey, conMgr connmgr.ConnManager, outgoingPLB p2p.ChannelLoadBalancer, peerDiscoverer p2p.PeerDiscoverer, listenAddress string, targetConnCount int, ) (*networkMessenger, error)
NewNetworkMessenger creates a libP2P messenger by opening a port on the current machine Should be used in production!
func NewNetworkMessengerOnFreePort ¶ added in v1.0.3
func NewNetworkMessengerOnFreePort( ctx context.Context, p2pPrivKey libp2pCrypto.PrivKey, conMgr connmgr.ConnManager, outgoingPLB p2p.ChannelLoadBalancer, peerDiscoverer p2p.PeerDiscoverer, ) (*networkMessenger, error)
NewNetworkMessengerOnFreePort tries to create a new NetworkMessenger on a free port found in the system Should be used only in testing!
Types ¶
type ConnectableHost ¶
type ConnectableHost interface { host.Host ConnectToPeer(ctx context.Context, address string) error IsInterfaceNil() bool }
ConnectableHost is an enhanced Host interface that has the ability to connect to a string address
type Libp2pContext ¶ added in v1.0.3
type Libp2pContext struct {
// contains filtered or unexported fields
}
Libp2pContext holds the context for the wrappers over libp2p implementation
func NewLibp2pContext ¶ added in v1.0.3
func NewLibp2pContext(ctx context.Context, connHost ConnectableHost) (*Libp2pContext, error)
NewLibp2pContext constructs a new Libp2pContext object
func (*Libp2pContext) Context ¶ added in v1.0.3
func (lctx *Libp2pContext) Context() context.Context
Context returns the context associated with this struct
func (*Libp2pContext) Host ¶ added in v1.0.3
func (lctx *Libp2pContext) Host() ConnectableHost
Host returns the connectable host
func (*Libp2pContext) IsInterfaceNil ¶ added in v1.0.16
func (lctx *Libp2pContext) IsInterfaceNil() bool
IsInterfaceNil returns true if there is no value under the interface
type Message ¶ added in v1.0.3
type Message struct {
// contains filtered or unexported fields
}
Message is a data holder struct
func NewMessage ¶
func NewMessage(message *pubsub.Message) *Message
NewMessage returns a new instance of a Message object
func (*Message) IsInterfaceNil ¶ added in v1.0.16
IsInterfaceNil returns true if there is no value under the interface
func (*Message) Key ¶ added in v1.0.3
Key returns the message public key (if it can not be recovered from From field)
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.
type PeerInfoHandler ¶
PeerInfoHandler is the signature of the handler that gets called whenever an action for a peerInfo is triggered