Documentation ¶
Index ¶
- func ConnectAsync(ctx context.Context, h lp2phost.Host, addrInfo lp2ppeer.AddrInfo, ...)
- func DetectPublicIPv4() (string, bool)
- func DetectPublicIPv6() (string, bool)
- func HasPID(pids []lp2ppeer.ID, pid lp2ppeer.ID) bool
- func IPToMultiAddr(ip string, port int) (multiaddr.Multiaddr, error)
- func LogScale(val int) int
- func MakeAddrInfos(addrs []string) ([]lp2ppeer.AddrInfo, error)
- func MakeAddressInfo(addr string) (*lp2ppeer.AddrInfo, error)
- func MakeMultiAddrs(addrs []string) ([]multiaddr.Multiaddr, error)
- func MakeScalingLimitConfig(minConns, maxConns int) lp2prcmgr.ScalingLimitConfig
- func PrivateSubnets() []*net.IPNet
- func SubnetsToFilters(subnets []*net.IPNet, action multiaddr.Action) *multiaddr.Filters
- type Config
- type ConnectEvent
- type ConnectionGater
- func (g *ConnectionGater) InterceptAccept(cma lp2pnetwork.ConnMultiaddrs) bool
- func (g *ConnectionGater) InterceptAddrDial(p lp2ppeer.ID, ma multiaddr.Multiaddr) bool
- func (g *ConnectionGater) InterceptPeerDial(p lp2ppeer.ID) bool
- func (g *ConnectionGater) InterceptSecured(dir lp2pnetwork.Direction, p lp2ppeer.ID, cma lp2pnetwork.ConnMultiaddrs) bool
- func (g *ConnectionGater) InterceptUpgraded(con lp2pnetwork.Conn) (bool, lp2pcontrol.DisconnectReason)
- func (g *ConnectionGater) SetLogger(log *logger.SubLogger)
- 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) IsClosed(pid lp2ppeer.ID) bool
- func (mock *MockNetwork) JoinConsensusTopic() error
- func (mock *MockNetwork) JoinGeneralTopic() error
- func (mock *MockNetwork) NumConnectedPeers() int
- 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 (n *NotifeeService) Connected(lp2pn lp2pnetwork.Network, conn lp2pnetwork.Conn)
- func (n *NotifeeService) Disconnected(_ lp2pnetwork.Network, conn lp2pnetwork.Conn)
- func (n *NotifeeService) Listen(_ lp2pnetwork.Network, ma multiaddr.Multiaddr)
- func (n *NotifeeService) ListenClose(_ lp2pnetwork.Network, ma multiaddr.Multiaddr)
- type PublishData
- type StreamMessage
- type TopicID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectAsync ¶ added in v0.15.0
func DetectPublicIPv4 ¶ added in v0.16.1
DetectPublicIPv4 returns the public IPv4 address of the local machine by dialing a list of specific IP addresses.
func DetectPublicIPv6 ¶ added in v0.16.1
DetectPublicIPv6 returns the public IPv6 address of the local machine by dialing a list of specific IPv6 addresses.
func IPToMultiAddr ¶ added in v0.16.1
func LogScale ¶ added in v0.16.1
LogScale computes 2^⌈log₂(val)⌉, where ⌈x⌉ represents the ceiling of x. For more information, refer to: https://en.wikipedia.org/wiki/Logarithmic_scale
func MakeAddrInfos ¶ added in v0.16.1
MakeAddrInfos converts a slice of string peer addresses to AddrInfo.
func MakeAddressInfo ¶ added in v0.15.0
MakeAddressInfo from Multi-address string.
func MakeMultiAddrs ¶ added in v0.16.1
MakeMultiAddrs converts a slice of string peer addresses to MultiAddress.
func MakeScalingLimitConfig ¶ added in v0.16.1
func MakeScalingLimitConfig(minConns, maxConns int) lp2prcmgr.ScalingLimitConfig
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"` PublicAddress []string `toml:"public_address"` Listens []string `toml:"listens"` RelayAddrs []string `toml:"relay_addresses"` BootstrapAddrs []string `toml:"bootstrap_addresses"` MinConns int `toml:"min_connections"` MaxConns int `toml:"max_connections"` EnableNAT bool `toml:"enable_nat"` EnableRelay bool `toml:"enable_relay"` EnableMdns bool `toml:"enable_mdns"` EnableMetrics bool `toml:"enable_metrics"` ForcePrivateNetwork bool `toml:"force_private_network"` Bootstrapper bool `toml:"bootstrapper"` // TODO: detect it automatically DefaultPort int `toml:"-"` }
func DefaultConfig ¶
func DefaultConfig() *Config
func (*Config) BasicCheck ¶ added in v0.15.0
BasicCheck performs basic checks on the configuration.
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 { *lp2pconngater.BasicConnectionGater // contains filtered or unexported fields }
func NewConnectionGater ¶ added in v0.16.1
func NewConnectionGater(conf *Config) (*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(p lp2ppeer.ID, ma multiaddr.Multiaddr) bool
func (*ConnectionGater) InterceptPeerDial ¶ added in v0.16.1
func (g *ConnectionGater) InterceptPeerDial(p lp2ppeer.ID) bool
func (*ConnectionGater) InterceptSecured ¶ added in v0.16.1
func (g *ConnectionGater) InterceptSecured(dir lp2pnetwork.Direction, p lp2ppeer.ID, cma lp2pnetwork.ConnMultiaddrs, ) bool
func (*ConnectionGater) InterceptUpgraded ¶ added in v0.16.1
func (g *ConnectionGater) InterceptUpgraded(con lp2pnetwork.Conn) (bool, lp2pcontrol.DisconnectReason)
func (*ConnectionGater) SetLogger ¶ added in v0.16.1
func (g *ConnectionGater) SetLogger(log *logger.SubLogger)
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. `Source` is the ID of the peer that initiate the message and `From` is the ID of the peer that we received a message from. They are not necessarily the same, especially in a decentralized network.
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) JoinConsensusTopic ¶
func (mock *MockNetwork) JoinConsensusTopic() error
func (*MockNetwork) JoinGeneralTopic ¶
func (mock *MockNetwork) JoinGeneralTopic() error
func (*MockNetwork) NumConnectedPeers ¶
func (mock *MockNetwork) NumConnectedPeers() int
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 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 (n *NotifeeService) Connected(lp2pn lp2pnetwork.Network, conn lp2pnetwork.Conn)
func (*NotifeeService) Disconnected ¶ added in v0.15.0
func (n *NotifeeService) Disconnected(_ lp2pnetwork.Network, conn lp2pnetwork.Conn)
func (*NotifeeService) Listen ¶ added in v0.15.0
func (n *NotifeeService) Listen(_ lp2pnetwork.Network, ma multiaddr.Multiaddr)
func (*NotifeeService) ListenClose ¶ added in v0.15.0
func (n *NotifeeService) ListenClose(_ lp2pnetwork.Network, ma multiaddr.Multiaddr)
ListenClose is called when your node stops listening on an address.
type PublishData ¶ added in v0.15.0
type StreamMessage ¶
type StreamMessage struct { Source lp2pcore.PeerID Reader io.ReadCloser }
StreamMessage represents message from stream module.
func (*StreamMessage) Type ¶
func (*StreamMessage) Type() EventType