Documentation ¶
Index ¶
- func ConnectAsync(ctx context.Context, h lp2phost.Host, addrInfo lp2ppeer.AddrInfo, ...)
- func ConnectSync(ctx context.Context, h lp2phost.Host, addrInfo lp2ppeer.AddrInfo) error
- func HasPID(pids []lp2ppeer.ID, pid lp2ppeer.ID) bool
- func IPToMultiAddr(ip string, port int) (multiaddr.Multiaddr, error)
- func MakeAddrInfos(addrs []string) ([]lp2ppeer.AddrInfo, error)
- func MakeMultiAddrs(addrs []string) ([]multiaddr.Multiaddr, error)
- func MessageIDFunc(m *lp2pspb.Message) string
- func PrivateSubnets() []*net.IPNet
- func SubnetsToFilters(subnets []*net.IPNet, action multiaddr.Action) *multiaddr.Filters
- type Config
- func (conf *Config) BasicCheck() error
- func (conf *Config) BootstrapAddrInfos() []lp2ppeer.AddrInfo
- func (conf *Config) CheckIsBootstrapper(pid lp2pcore.PeerID)
- func (conf *Config) ListenAddrs() []multiaddr.Multiaddr
- func (conf *Config) MinConns() int
- func (conf *Config) PublicAddr() multiaddr.Multiaddr
- type ConfigError
- type ConnectEvent
- type ConnectionGater
- func (g *ConnectionGater) InterceptAccept(cma lp2pnetwork.ConnMultiaddrs) bool
- func (g *ConnectionGater) InterceptAddrDial(pid lp2ppeer.ID, ma multiaddr.Multiaddr) bool
- func (g *ConnectionGater) InterceptPeerDial(pid lp2ppeer.ID) bool
- func (g *ConnectionGater) InterceptSecured(_ lp2pnetwork.Direction, _ lp2ppeer.ID, _ lp2pnetwork.ConnMultiaddrs) bool
- func (g *ConnectionGater) InterceptUpgraded(_ lp2pnetwork.Conn) (bool, lp2pcontrol.DisconnectReason)
- func (g *ConnectionGater) SetPeerManager(peerMgr *peerMgr)
- type DisconnectEvent
- type Event
- type EventType
- type GossipMessage
- type InvalidTopicError
- type LibP2PError
- type MockNetwork
- func (mock *MockNetwork) AddAnotherNetwork(net *MockNetwork)
- func (mock *MockNetwork) Broadcast(data []byte, _ TopicID) error
- func (mock *MockNetwork) CloseConnection(pid lp2ppeer.ID)
- func (mock *MockNetwork) EventChannel() <-chan Event
- func (mock *MockNetwork) HostAddrs() []string
- func (mock *MockNetwork) IsClosed(pid lp2ppeer.ID) bool
- func (mock *MockNetwork) JoinConsensusTopic(_ ShouldPropagate) error
- func (mock *MockNetwork) JoinGeneralTopic(_ ShouldPropagate) error
- func (mock *MockNetwork) Name() string
- func (mock *MockNetwork) NumConnectedPeers() int
- func (mock *MockNetwork) NumInbound() int
- func (mock *MockNetwork) NumOutbound() int
- func (mock *MockNetwork) Protect(_ lp2pcore.PeerID, _ string)
- func (mock *MockNetwork) Protocols() []string
- func (mock *MockNetwork) ReachabilityStatus() string
- func (mock *MockNetwork) SelfID() lp2ppeer.ID
- func (mock *MockNetwork) SendTo(data []byte, pid lp2pcore.PeerID) error
- func (mock *MockNetwork) SendToOthers(data []byte, target *lp2ppeer.ID)
- func (mock *MockNetwork) Start() error
- func (mock *MockNetwork) Stop()
- type Network
- type NotSubscribedError
- type NotifeeService
- func (s *NotifeeService) Connected(_ lp2pnetwork.Network, conn lp2pnetwork.Conn)
- func (s *NotifeeService) Disconnected(_ lp2pnetwork.Network, conn lp2pnetwork.Conn)
- func (s *NotifeeService) Listen(_ lp2pnetwork.Network, ma multiaddr.Multiaddr)
- func (s *NotifeeService) ListenClose(_ lp2pnetwork.Network, ma multiaddr.Multiaddr)
- func (s *NotifeeService) Reachability() lp2pnetwork.Reachability
- func (s *NotifeeService) Start()
- func (s *NotifeeService) Stop()
- type ProtocolsEvents
- type PublishData
- type ShouldPropagate
- type StreamMessage
- type TopicID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectAsync ¶ added in v0.15.0
func ConnectSync ¶ added in v0.19.0
func IPToMultiAddr ¶ added in v0.16.1
func MakeAddrInfos ¶ added in v0.16.1
MakeAddrInfos converts a slice of string peer addresses to AddrInfo.
func MakeMultiAddrs ¶ added in v0.16.1
MakeMultiAddrs converts a slice of string peer addresses to MultiAddress.
func MessageIDFunc ¶ added in v0.17.0
func PrivateSubnets ¶ added in v0.16.1
func SubnetsToFilters ¶ added in v0.16.1
Types ¶
type Config ¶
type Config struct { NetworkKey string `toml:"network_key"` PublicAddrString string `toml:"public_addr"` ListenAddrStrings []string `toml:"listen_addrs"` BootstrapAddrStrings []string `toml:"bootstrap_addrs"` MaxConns int `toml:"max_connections"` EnableUDP bool `toml:"enable_udp"` EnableNATService bool `toml:"enable_nat_service"` EnableUPnP bool `toml:"enable_upnp"` EnableRelay bool `toml:"enable_relay"` EnableRelayService bool `toml:"enable_relay_service"` EnableMdns bool `toml:"enable_mdns"` EnableMetrics bool `toml:"enable_metrics"` ForcePrivateNetwork bool `toml:"force_private_network"` RateLimitThreshold int `toml:"rate_limit_threshold"` // Private configs NetworkName string `toml:"-"` DefaultPort int `toml:"-"` DefaultBootstrapAddrStrings []string `toml:"-"` IsBootstrapper bool `toml:"-"` }
func DefaultConfig ¶
func DefaultConfig() *Config
func (*Config) BasicCheck ¶ added in v0.15.0
BasicCheck performs basic checks on the configuration.
func (*Config) BootstrapAddrInfos ¶ added in v0.17.0
func (*Config) CheckIsBootstrapper ¶ added in v0.18.3
func (*Config) ListenAddrs ¶ added in v0.17.0
func (conf *Config) ListenAddrs() []multiaddr.Multiaddr
func (*Config) PublicAddr ¶ added in v0.17.0
func (conf *Config) PublicAddr() multiaddr.Multiaddr
type ConfigError ¶ added in v0.20.0
type ConfigError struct {
Reason string
}
ConfigError is returned when the config is not valid with a descriptive Reason message.
func (ConfigError) Error ¶ added in v0.20.0
func (e ConfigError) Error() string
type ConnectEvent ¶ added in v0.15.0
ConnectEvent represents a peer connection event.
func (*ConnectEvent) Type ¶ added in v0.15.0
func (*ConnectEvent) Type() EventType
type ConnectionGater ¶ added in v0.16.1
type ConnectionGater struct {
// contains filtered or unexported fields
}
func NewConnectionGater ¶ added in v0.16.1
func NewConnectionGater(conf *Config, log *logger.SubLogger) (*ConnectionGater, error)
func (*ConnectionGater) InterceptAccept ¶ added in v0.16.1
func (g *ConnectionGater) InterceptAccept(cma lp2pnetwork.ConnMultiaddrs) bool
func (*ConnectionGater) InterceptAddrDial ¶ added in v0.16.1
func (g *ConnectionGater) InterceptAddrDial(pid lp2ppeer.ID, ma multiaddr.Multiaddr) bool
func (*ConnectionGater) InterceptPeerDial ¶ added in v0.16.1
func (g *ConnectionGater) InterceptPeerDial(pid lp2ppeer.ID) bool
func (*ConnectionGater) InterceptSecured ¶ added in v0.16.1
func (g *ConnectionGater) InterceptSecured(_ lp2pnetwork.Direction, _ lp2ppeer.ID, _ lp2pnetwork.ConnMultiaddrs) bool
func (*ConnectionGater) InterceptUpgraded ¶ added in v0.16.1
func (g *ConnectionGater) InterceptUpgraded(_ lp2pnetwork.Conn) (bool, lp2pcontrol.DisconnectReason)
func (*ConnectionGater) SetPeerManager ¶ added in v0.17.0
func (g *ConnectionGater) SetPeerManager(peerMgr *peerMgr)
type DisconnectEvent ¶ added in v0.15.0
DisconnectEvent represents a peer disconnection event.
func (*DisconnectEvent) Type ¶ added in v0.15.0
func (*DisconnectEvent) Type() EventType
type GossipMessage ¶
GossipMessage represents message from PubSub module. `From` is the ID of the peer that we received a message from.
func (*GossipMessage) Type ¶
func (*GossipMessage) Type() EventType
type InvalidTopicError ¶ added in v0.15.0
type InvalidTopicError struct {
TopicID TopicID
}
InvalidTopicError is returned when the Pub-Sub topic is invalid.
func (InvalidTopicError) Error ¶ added in v0.15.0
func (e InvalidTopicError) Error() string
type LibP2PError ¶ added in v0.15.0
type LibP2PError struct {
Err error
}
LibP2PError is returned when an underlying libp2p operation encounters an error.
func (LibP2PError) Error ¶ added in v0.15.0
func (e LibP2PError) Error() string
type MockNetwork ¶
type MockNetwork struct { *testsuite.TestSuite PublishCh chan PublishData EventCh chan Event ID lp2ppeer.ID OtherNets []*MockNetwork SendError error }
func MockingNetwork ¶
func MockingNetwork(ts *testsuite.TestSuite, id lp2ppeer.ID) *MockNetwork
func (*MockNetwork) AddAnotherNetwork ¶
func (mock *MockNetwork) AddAnotherNetwork(net *MockNetwork)
func (*MockNetwork) CloseConnection ¶
func (mock *MockNetwork) CloseConnection(pid lp2ppeer.ID)
func (*MockNetwork) EventChannel ¶
func (mock *MockNetwork) EventChannel() <-chan Event
func (*MockNetwork) HostAddrs ¶ added in v0.18.0
func (mock *MockNetwork) HostAddrs() []string
func (*MockNetwork) JoinConsensusTopic ¶
func (mock *MockNetwork) JoinConsensusTopic(_ ShouldPropagate) error
func (*MockNetwork) JoinGeneralTopic ¶
func (mock *MockNetwork) JoinGeneralTopic(_ ShouldPropagate) error
func (*MockNetwork) Name ¶ added in v0.19.0
func (mock *MockNetwork) Name() string
func (*MockNetwork) NumConnectedPeers ¶
func (mock *MockNetwork) NumConnectedPeers() int
func (*MockNetwork) NumInbound ¶ added in v1.0.1
func (mock *MockNetwork) NumInbound() int
func (*MockNetwork) NumOutbound ¶ added in v1.0.1
func (mock *MockNetwork) NumOutbound() int
func (*MockNetwork) Protect ¶ added in v0.17.0
func (mock *MockNetwork) Protect(_ lp2pcore.PeerID, _ string)
func (*MockNetwork) Protocols ¶ added in v0.19.0
func (mock *MockNetwork) Protocols() []string
func (*MockNetwork) ReachabilityStatus ¶ added in v0.18.0
func (mock *MockNetwork) ReachabilityStatus() string
func (*MockNetwork) SelfID ¶
func (mock *MockNetwork) SelfID() lp2ppeer.ID
func (*MockNetwork) SendTo ¶
func (mock *MockNetwork) SendTo(data []byte, pid lp2pcore.PeerID) error
func (*MockNetwork) SendToOthers ¶
func (mock *MockNetwork) SendToOthers(data []byte, target *lp2ppeer.ID)
func (*MockNetwork) Start ¶
func (mock *MockNetwork) Start() error
func (*MockNetwork) Stop ¶
func (mock *MockNetwork) Stop()
type Network ¶
type Network interface { Start() error Stop() Protect(lp2pcore.PeerID, string) EventChannel() <-chan Event Broadcast([]byte, TopicID) error SendTo([]byte, lp2pcore.PeerID) error JoinGeneralTopic(shouldPropagate ShouldPropagate) error JoinConsensusTopic(shouldPropagate ShouldPropagate) error CloseConnection(pid lp2pcore.PeerID) SelfID() lp2pcore.PeerID NumConnectedPeers() int NumInbound() int NumOutbound() int ReachabilityStatus() string HostAddrs() []string Name() string Protocols() []string }
func NewNetwork ¶
type NotSubscribedError ¶ added in v0.15.0
type NotSubscribedError struct {
TopicID TopicID
}
NotSubscribedError is returned when the peer is not subscribed to a specific topic.
func (NotSubscribedError) Error ¶ added in v0.15.0
func (e NotSubscribedError) Error() string
type NotifeeService ¶ added in v0.15.0
type NotifeeService struct {
// contains filtered or unexported fields
}
func (*NotifeeService) Connected ¶ added in v0.15.0
func (s *NotifeeService) Connected(_ lp2pnetwork.Network, conn lp2pnetwork.Conn)
func (*NotifeeService) Disconnected ¶ added in v0.15.0
func (s *NotifeeService) Disconnected(_ lp2pnetwork.Network, conn lp2pnetwork.Conn)
func (*NotifeeService) Listen ¶ added in v0.15.0
func (s *NotifeeService) Listen(_ lp2pnetwork.Network, ma multiaddr.Multiaddr)
func (*NotifeeService) ListenClose ¶ added in v0.15.0
func (s *NotifeeService) ListenClose(_ lp2pnetwork.Network, ma multiaddr.Multiaddr)
ListenClose is called when your node stops listening on an address.
func (*NotifeeService) Reachability ¶ added in v0.20.0
func (s *NotifeeService) Reachability() lp2pnetwork.Reachability
func (*NotifeeService) Start ¶ added in v0.18.0
func (s *NotifeeService) Start()
func (*NotifeeService) Stop ¶ added in v0.18.0
func (s *NotifeeService) Stop()
type ProtocolsEvents ¶ added in v0.18.0
ProtocolsEvents represents updating protocols event.
func (*ProtocolsEvents) Type ¶ added in v0.18.0
func (*ProtocolsEvents) Type() EventType
type PublishData ¶ added in v0.15.0
type ShouldPropagate ¶ added in v0.17.0
type ShouldPropagate func(*GossipMessage) bool
ShouldPropagate determines whether a message should be disregarded: it will be neither delivered to the application nor forwarded to the network.
type StreamMessage ¶
type StreamMessage struct { From lp2pcore.PeerID Reader io.ReadCloser }
StreamMessage represents message from Stream module. `From` is the ID of the peer that we received a message from.
func (*StreamMessage) Type ¶
func (*StreamMessage) Type() EventType