Documentation ¶
Overview ¶
Package net net utils
Index ¶
- func ConvertPeers(peers []string) map[string]*peer.AddrInfo
- type Discovery
- func (d *Discovery) Close() error
- func (d *Discovery) CloseFindLANPeers()
- func (d *Discovery) FindLANPeers(host host.Host, serviceTag string) (<-chan peer.AddrInfo, error)
- func (d *Discovery) FindLocalPeer(pid peer.ID) peer.AddrInfo
- func (d *Discovery) FindLocalPeers(pids []peer.ID) []peer.AddrInfo
- func (d *Discovery) FindNearestPeers(pid peer.ID, count int) []peer.ID
- func (d *Discovery) FindPeers(RendezvousString string, gossip bool) ([]peer.AddrInfo, error)
- func (d *Discovery) FindPeersConnectedToPeer(pid peer.ID) (<-chan *peer.AddrInfo, error)
- func (d *Discovery) FindSpecialPeer(pid peer.ID) (*peer.AddrInfo, error)
- func (d *Discovery) ListPeers() []peer.ID
- func (d *Discovery) Remove(pid peer.ID)
- func (d *Discovery) RoutingTable() *kbt.RoutingTable
- func (d *Discovery) RoutingTableSize() int
- func (d *Discovery) Start()
- func (d *Discovery) Update(pid peer.ID) error
- type PubSub
- func (p *PubSub) FetchTopicPeers(topic string) []peer.ID
- func (p *PubSub) GetTopics() []string
- func (p *PubSub) HasTopic(topic string) bool
- func (p *PubSub) JoinAndSubTopic(topic string, callback SubCallBack, opts ...pubsub.TopicOpt) error
- func (p *PubSub) Publish(topic string, msg []byte) error
- func (p *PubSub) RemoveTopic(topic string)
- func (p *PubSub) TopicNum() int
- type Relay
- type SubCallBack
- type SubMsg
- type TopicMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Discovery ¶
type Discovery struct { RoutingDiscovery *discovery.RoutingDiscovery // contains filtered or unexported fields }
Discovery dht discovery
func InitDhtDiscovery ¶
func InitDhtDiscovery(ctx context.Context, host host.Host, peersInfo []peer.AddrInfo, chainCfg *types.Chain33Config, subCfg *p2pty.P2PSubConfig) *Discovery
InitDhtDiscovery init dht discovery
func (*Discovery) CloseFindLANPeers ¶
func (d *Discovery) CloseFindLANPeers()
CloseFindLANPeers close peers
func (*Discovery) FindLANPeers ¶
FindLANPeers 查找局域网内的其他节点
func (*Discovery) FindLocalPeer ¶
FindLocalPeer 根据pid 查找当前DHT内部的peer信息
func (*Discovery) FindLocalPeers ¶
FindLocalPeers find local peers
func (*Discovery) FindNearestPeers ¶
FindNearestPeers find nearest peers
func (*Discovery) FindPeersConnectedToPeer ¶
FindPeersConnectedToPeer 获取连接指定的peerId的peers信息,查找连接PID=A的所有节点
func (*Discovery) FindSpecialPeer ¶
FindSpecialPeer 根据指定的peerID ,查找指定的peer,
func (*Discovery) RoutingTable ¶ added in v1.65.0
func (d *Discovery) RoutingTable() *kbt.RoutingTable
RoutingTable get routing table
func (*Discovery) RoutingTableSize ¶
RoutingTableSize routingTable size
type PubSub ¶ added in v1.65.0
type PubSub struct {
// contains filtered or unexported fields
}
PubSub pub sub
func (*PubSub) FetchTopicPeers ¶ added in v1.65.0
FetchTopicPeers fetch peers with topic
func (*PubSub) JoinAndSubTopic ¶ added in v1.65.0
JoinAndSubTopic 加入topic&subTopic
func (*PubSub) RemoveTopic ¶ added in v1.65.0
RemoveTopic remove topic
type Relay ¶ added in v1.65.0
type Relay struct {
// contains filtered or unexported fields
}
Relay p2p relay
func NewRelayDiscovery ¶ added in v1.65.0
func NewRelayDiscovery(host host.Host, adv *discovery.RoutingDiscovery, opts ...circuit.RelayOpt) *Relay
NewRelayDiscovery new relay discovery
func (*Relay) DialDestPeer ¶ added in v1.65.0
DialDestPeer 通过hop中继节点连接dst节点
type SubCallBack ¶ added in v1.65.0
SubCallBack 订阅消息回调函数
Click to show internal directories.
Click to hide internal directories.