Documentation ¶
Overview ¶
Package dht 基于libp2p实现p2p 插件
Index ¶
- func GenPrivPubkey() ([]byte, []byte, error)
- func GenPubkey(key string) (string, error)
- func New(mgr *p2p.Manager, subCfg []byte) p2p.IP2P
- func PeerIDToPubkey(id string) (string, error)
- type AddrBook
- func (a *AddrBook) AddrsInfo() []peer.AddrInfo
- func (a *AddrBook) GetPrivPubKey() (string, string)
- func (a *AddrBook) GetPrivkey() crypto.PrivKey
- func (a *AddrBook) Randkey() crypto.PrivKey
- func (a *AddrBook) SaveAddr(addrinfos []peer.AddrInfo) error
- func (a *AddrBook) StoreHostID(id peer.ID, path string)
- 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) 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) Start()
- func (d *Discovery) Update(pid peer.ID) error
- type P2P
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenPrivPubkey ¶
GenPrivPubkey return key and pubkey in bytes
func PeerIDToPubkey ¶
PeerIDToPubkey 提供节点ID转换为pubkey,进而通过pubkey创建turingchain 地址的功能
Types ¶
type AddrBook ¶
type AddrBook struct {
// contains filtered or unexported fields
}
AddrBook peer address manager
func (*AddrBook) GetPrivPubKey ¶
GetPrivPubKey return privkey and pubkey
func (*AddrBook) GetPrivkey ¶
GetPrivkey get private key
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.TuringchainConfig, 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 ¶
func (d *Discovery) RoutingTable() *kbt.RoutingTable
RoutingTable get routing table
Click to show internal directories.
Click to hide internal directories.