Documentation ¶
Index ¶
- Constants
- func NewConnectableHost(h host.Host) *connectableHost
- func NewDirectSender(ctx context.Context, h host.Host, ...) (*directSender, error)
- func NewMessage(msg *pubsub.Message, marshalizer p2p.Marshalizer) (*message.Message, error)
- func NewMockMessenger(args ArgsNetworkMessenger, mockNet mocknet.Mocknet) (*networkMessenger, error)
- func NewNetworkMessenger(args ArgsNetworkMessenger) (*networkMessenger, error)
- type ArgsNetworkMessenger
- type ConnectableHost
- type ConnectionMonitor
- type LocalSyncTimer
- type MutexHolder
- type PeerDiscovererWithSharder
- type PeerInfoHandler
Constants ¶
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 ¶
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 ¶
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.
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 ¶
PeerInfoHandler is the signature of the handler that gets called whenever an action for a peerInfo is triggered