Documentation
¶
Index ¶
- Constants
- func LoadPeers(h host.Host, peers []*peer.AddrInfo)
- func NewHost(privKey crypto.PrivKey, networkTopology *topology.NetworkTopology, ...) (host.Host, error)
- func ReadStream(r *bufio.Reader) ([]byte, error)
- func WriteStream(msg []byte, w *bufio.Writer) error
- type ConnectionGate
- func (cg *ConnectionGate) InterceptAccept(network.ConnMultiaddrs) (allow bool)
- func (cg *ConnectionGate) InterceptAddrDial(peer.ID, ma.Multiaddr) (allow bool)
- func (cg *ConnectionGate) InterceptPeerDial(p peer.ID) (allow bool)
- func (cg *ConnectionGate) InterceptSecured(nd network.Direction, p peer.ID, cm network.ConnMultiaddrs) (allow bool)
- func (cg *ConnectionGate) InterceptUpgraded(network.Conn) (allow bool, reason control.DisconnectReason)
- func (cg *ConnectionGate) SetTopology(topology *topology.NetworkTopology)
- type Libp2pCommunication
- func (c Libp2pCommunication) Broadcast(peers peer.IDSlice, msg []byte, msgType comm.MessageType, sessionID string) error
- func (c Libp2pCommunication) CloseSession(sessionID string)
- func (c Libp2pCommunication) ProcessMessagesFromStream(s network.Stream)
- func (c Libp2pCommunication) StreamHandlerFunc(s network.Stream)
- func (c Libp2pCommunication) Subscribe(sessionID string, msgType comm.MessageType, channel chan *comm.WrappedMessage) comm.SubscriptionID
- func (c Libp2pCommunication) UnSubscribe(subID comm.SubscriptionID)
- type Metrics
- type NoopMetrics
- type SessionSubscriptionManager
- func (ms *SessionSubscriptionManager) GetSubscribers(sessionID string, msgType comm.MessageType) []chan *comm.WrappedMessage
- func (ms *SessionSubscriptionManager) SubscribeTo(sessionID string, msgType comm.MessageType, channel chan *comm.WrappedMessage) comm.SubscriptionID
- func (ms *SessionSubscriptionManager) UnSubscribeFrom(subscriptionID comm.SubscriptionID)
- type StreamManager
Constants ¶
View Source
const (
STREAM_TIMEOUT = time.Second * 5
)
Variables ¶
This section is empty.
Functions ¶
func NewHost ¶
func NewHost(privKey crypto.PrivKey, networkTopology *topology.NetworkTopology, cg *ConnectionGate, port uint16) (host.Host, error)
NewHost creates new host.Host from private key and relayer configuration
func ReadStream ¶
ReadStream reads data from the given stream
Types ¶
type ConnectionGate ¶
type ConnectionGate struct {
// contains filtered or unexported fields
}
ConnectionGate implements libp2p ConnectionGater to prevent inbound and outbound requests to peers not specified in topology
func NewConnectionGate ¶
func NewConnectionGate(topology *topology.NetworkTopology) *ConnectionGate
func (*ConnectionGate) InterceptAccept ¶
func (cg *ConnectionGate) InterceptAccept(network.ConnMultiaddrs) (allow bool)
func (*ConnectionGate) InterceptAddrDial ¶
func (*ConnectionGate) InterceptPeerDial ¶
func (cg *ConnectionGate) InterceptPeerDial(p peer.ID) (allow bool)
func (*ConnectionGate) InterceptSecured ¶
func (cg *ConnectionGate) InterceptSecured(nd network.Direction, p peer.ID, cm network.ConnMultiaddrs) (allow bool)
func (*ConnectionGate) InterceptUpgraded ¶
func (cg *ConnectionGate) InterceptUpgraded(network.Conn) (allow bool, reason control.DisconnectReason)
func (*ConnectionGate) SetTopology ¶
func (cg *ConnectionGate) SetTopology(topology *topology.NetworkTopology)
type Libp2pCommunication ¶
type Libp2pCommunication struct {
SessionSubscriptionManager
// contains filtered or unexported fields
}
func NewCommunication ¶
func (Libp2pCommunication) Broadcast ¶
func (c Libp2pCommunication) Broadcast( peers peer.IDSlice, msg []byte, msgType comm.MessageType, sessionID string, ) error
func (Libp2pCommunication) CloseSession ¶
func (c Libp2pCommunication) CloseSession(sessionID string)
func (Libp2pCommunication) ProcessMessagesFromStream ¶
func (c Libp2pCommunication) ProcessMessagesFromStream(s network.Stream)
func (Libp2pCommunication) StreamHandlerFunc ¶
func (c Libp2pCommunication) StreamHandlerFunc(s network.Stream)
func (Libp2pCommunication) Subscribe ¶
func (c Libp2pCommunication) Subscribe( sessionID string, msgType comm.MessageType, channel chan *comm.WrappedMessage, ) comm.SubscriptionID
func (Libp2pCommunication) UnSubscribe ¶
func (c Libp2pCommunication) UnSubscribe( subID comm.SubscriptionID, )
type Metrics ¶ added in v1.2.0
type Metrics interface {
RecordCommSend(peer string, d time.Duration)
RecordCommDnsResolve(d time.Duration)
}
Metrics records timing for outbound libp2p sends. The concrete implementation lives in the metrics package; NoopMetrics is provided here for callers that do not need telemetry (health check comms, tests).
type NoopMetrics ¶ added in v1.2.0
type NoopMetrics struct{}
func (NoopMetrics) RecordCommDnsResolve ¶ added in v1.2.0
func (NoopMetrics) RecordCommDnsResolve(d time.Duration)
func (NoopMetrics) RecordCommSend ¶ added in v1.2.0
func (NoopMetrics) RecordCommSend(peer string, d time.Duration)
type SessionSubscriptionManager ¶
type SessionSubscriptionManager struct {
// contains filtered or unexported fields
}
SessionSubscriptionManager manages channel subscriptions by comm.SessionID
func NewSessionSubscriptionManager ¶
func NewSessionSubscriptionManager() SessionSubscriptionManager
func (*SessionSubscriptionManager) GetSubscribers ¶
func (ms *SessionSubscriptionManager) GetSubscribers( sessionID string, msgType comm.MessageType, ) []chan *comm.WrappedMessage
func (*SessionSubscriptionManager) SubscribeTo ¶
func (ms *SessionSubscriptionManager) SubscribeTo( sessionID string, msgType comm.MessageType, channel chan *comm.WrappedMessage, ) comm.SubscriptionID
func (*SessionSubscriptionManager) UnSubscribeFrom ¶
func (ms *SessionSubscriptionManager) UnSubscribeFrom( subscriptionID comm.SubscriptionID, )
type StreamManager ¶
type StreamManager struct {
// contains filtered or unexported fields
}
StreamManager manages instances of network.Stream
func NewStreamManager ¶
func NewStreamManager(host host.Host, protocolID protocol.ID) *StreamManager
NewStreamManager creates new StreamManager
func (*StreamManager) CloseStream ¶ added in v1.0.2
func (sm *StreamManager) CloseStream(peerID peer.ID)
CloseStream closes stream to the peer
Directories
¶
| Path | Synopsis |
|---|---|
|
mock
|
|
|
conn
Package mock_network is a generated GoMock package.
|
Package mock_network is a generated GoMock package. |
|
host
Package mock_host is a generated GoMock package.
|
Package mock_host is a generated GoMock package. |
|
stream
Package mock_network is a generated GoMock package.
|
Package mock_network is a generated GoMock package. |
Click to show internal directories.
Click to hide internal directories.