Documentation
¶
Index ¶
- Constants
- func NewConnectableHost(h host.Host) *connectableHost
- func NewConnectionsHandler(args ArgConnectionsHandler) (*connectionsHandler, error)
- func NewDirectSender(ctx context.Context, h host.Host, signer p2p.SignerVerifier, ...) (*directSender, error)
- func NewMessage(msg *pubsub.Message, marshaller p2p.Marshaller, ...) (*message.Message, error)
- func NewMessagesHandler(args ArgMessagesHandler) (*messagesHandler, error)
- func NewMockMessenger(args ArgsNetworkMessenger, mockNet mocknet.Mocknet) (*networkMessenger, error)
- func NewNetworkMessenger(args ArgsNetworkMessenger) (*networkMessenger, error)
- type ArgConnectionsHandler
- type ArgMessagesHandler
- type ArgsNetworkMessenger
- type ChannelLoadBalancer
- type ConnectableHost
- type ConnectionMonitor
- type ConnectionsMetric
- type LocalSyncTimer
- type MutexHolder
- type OutgoingChannelLoadBalancer
- func (oplb *OutgoingChannelLoadBalancer) AddChannel(channel string) error
- func (oplb *OutgoingChannelLoadBalancer) Close() error
- func (oplb *OutgoingChannelLoadBalancer) CollectOneElementFromChannels() *SendableData
- func (oplb *OutgoingChannelLoadBalancer) GetChannelOrDefault(channel string) chan *SendableData
- func (oplb *OutgoingChannelLoadBalancer) IsInterfaceNil() bool
- func (oplb *OutgoingChannelLoadBalancer) RemoveChannel(channel string) error
- type PeerDiscovererWithSharder
- type PeerInfoHandler
- type PeersOnChannel
- type PubSub
- type PubSubSubscription
- type PubSubTopic
- type SendableData
- type TopicProcessor
Constants ¶
const ( // TestListenAddrWithIp4AndTcp defines the local host listening ip v.4 address and TCP used in testing TestListenAddrWithIp4AndTcp = "/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 NewConnectionsHandler ¶
func NewConnectionsHandler(args ArgConnectionsHandler) (*connectionsHandler, error)
NewConnectionsHandler creates a new connections manager
func NewDirectSender ¶
func NewDirectSender( ctx context.Context, h host.Host, signer p2p.SignerVerifier, marshaller p2p.Marshaller, ) (*directSender, error)
NewDirectSender returns a new instance of direct sender object
func NewMessage ¶
func NewMessage(msg *pubsub.Message, marshaller p2p.Marshaller, broadcastMethod p2p.BroadcastMethod) (*message.Message, error)
NewMessage returns a new instance of a Message object
func NewMessagesHandler ¶
func NewMessagesHandler(args ArgMessagesHandler) (*messagesHandler, error)
NewMessagesHandler creates a new instance of messages handler
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 ArgConnectionsHandler ¶
type ArgConnectionsHandler struct {
P2pHost ConnectableHost
PeersOnChannel PeersOnChannel
PeerShardResolver p2p.PeerShardResolver
Sharder p2p.Sharder
PreferredPeersHolder p2p.PreferredPeersHolderHandler
ConnMonitor ConnectionMonitor
PeerDiscoverer p2p.PeerDiscoverer
PeerID core.PeerID
ConnectionsMetric ConnectionsMetric
}
ArgConnectionsHandler is the DTO struct used to create a new instance of connections handler
type ArgMessagesHandler ¶
type ArgMessagesHandler struct {
PubSub PubSub
DirectSender p2p.DirectSender
Throttler core.Throttler
OutgoingCLB ChannelLoadBalancer
Marshaller p2p.Marshaller
ConnMonitor ConnectionMonitor
PeersRatingHandler p2p.PeersRatingHandler
Debugger p2p.Debugger
SyncTimer p2p.SyncTimer
PeerID core.PeerID
}
ArgMessagesHandler is the DTO struct used to create a new instance of messages handler
type ArgsNetworkMessenger ¶
type ArgsNetworkMessenger struct {
ListenAddress string
Marshaller p2p.Marshaller
P2pConfig config.P2PConfig
SyncTimer p2p.SyncTimer
PreferredPeersHolder p2p.PreferredPeersHolderHandler
NodeOperationMode p2p.NodeOperation
PeersRatingHandler p2p.PeersRatingHandler
ConnectionWatcherType string
P2pPrivateKey commonCrypto.PrivateKey
P2pSingleSigner commonCrypto.SingleSigner
P2pKeyGenerator commonCrypto.KeyGenerator
}
ArgsNetworkMessenger defines the options used to create a p2p wrapper
type ChannelLoadBalancer ¶
type ChannelLoadBalancer interface {
AddChannel(channel string) error
RemoveChannel(channel string) error
GetChannelOrDefault(channel string) chan *SendableData
CollectOneElementFromChannels() *SendableData
Close() error
IsInterfaceNil() bool
}
ChannelLoadBalancer defines what a load balancer that uses chans should do
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
SetPeerDenialEvaluator(handler p2p.PeerDenialEvaluator) error
PeerDenialEvaluator() p2p.PeerDenialEvaluator
Close() error
IsInterfaceNil() bool
}
ConnectionMonitor defines the behavior of a connection monitor
type ConnectionsMetric ¶
type ConnectionsMetric interface {
network.Notifiee
ResetNumConnections() uint32
ResetNumDisconnections() uint32
IsInterfaceNil() bool
}
ConnectionsMetric is an extension of the libp2p network notifiee able to track connections metrics
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 OutgoingChannelLoadBalancer ¶
type OutgoingChannelLoadBalancer struct {
// contains filtered or unexported fields
}
OutgoingChannelLoadBalancer is a component that evenly balances requests to be sent
func NewOutgoingChannelLoadBalancer ¶
func NewOutgoingChannelLoadBalancer() *OutgoingChannelLoadBalancer
NewOutgoingChannelLoadBalancer creates a new instance of a ChannelLoadBalancer instance
func (*OutgoingChannelLoadBalancer) AddChannel ¶
func (oplb *OutgoingChannelLoadBalancer) AddChannel(channel string) error
AddChannel adds a new channel to the throttler, if it does not exists
func (*OutgoingChannelLoadBalancer) Close ¶
func (oplb *OutgoingChannelLoadBalancer) Close() error
Close finishes all started go routines in this instance
func (*OutgoingChannelLoadBalancer) CollectOneElementFromChannels ¶
func (oplb *OutgoingChannelLoadBalancer) CollectOneElementFromChannels() *SendableData
CollectOneElementFromChannels gets the waiting object from mainChan. It is a blocking call.
func (*OutgoingChannelLoadBalancer) GetChannelOrDefault ¶
func (oplb *OutgoingChannelLoadBalancer) GetChannelOrDefault(channel string) chan *SendableData
GetChannelOrDefault fetches the required channel or the default if the channel is not present
func (*OutgoingChannelLoadBalancer) IsInterfaceNil ¶
func (oplb *OutgoingChannelLoadBalancer) IsInterfaceNil() bool
IsInterfaceNil returns true if there is no value under the interface
func (*OutgoingChannelLoadBalancer) RemoveChannel ¶
func (oplb *OutgoingChannelLoadBalancer) RemoveChannel(channel string) error
RemoveChannel removes an existing channel from the throttler
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
type PeersOnChannel ¶
type PeersOnChannel interface {
ConnectedPeersOnChannel(topic string) []core.PeerID
Close() error
IsInterfaceNil() bool
}
PeersOnChannel interface defines what a component able to handle peers on a channel should do
type PubSub ¶
type PubSub interface {
Join(topic string, opts ...pubsub.TopicOpt) (*pubsub.Topic, error)
ListPeers(topic string) []peer.ID
RegisterTopicValidator(topic string, val interface{}, opts ...pubsub.ValidatorOpt) error
UnregisterTopicValidator(topic string) error
GetTopics() []string
}
PubSub interface defines what a publish/subscribe system should do
type PubSubSubscription ¶
type PubSubSubscription interface {
Topic() string
Next(ctx context.Context) (*pubsub.Message, error)
Cancel()
}
PubSubSubscription interface defines what a pubSub subscription can do
type PubSubTopic ¶
type PubSubTopic interface {
Subscribe(opts ...pubsub.SubOpt) (*pubsub.Subscription, error)
Publish(ctx context.Context, data []byte, opts ...pubsub.PubOpt) error
Close() error
}
PubSubTopic interface defines what a pubSub topic can do
type SendableData ¶
SendableData represents the struct used in data throttler implementation
type TopicProcessor ¶
type TopicProcessor interface {
AddTopicProcessor(identifier string, processor p2p.MessageProcessor) error
RemoveTopicProcessor(identifier string) error
GetList() ([]string, []p2p.MessageProcessor)
IsInterfaceNil() bool
}
TopicProcessor interface defines what a topic processor can do