mirror of
https://github.com/PeernetOfficial/core.git
synced 2026-07-16 18:37:51 +01:00
NodelistLookup function
This commit is contained in:
@@ -182,9 +182,7 @@ func IsNodeContact(nodeID []byte) (node *dht.Node, peer *PeerInfo) {
|
||||
// FindNode finds a node via the DHT
|
||||
func FindNode(nodeID []byte, Timeout time.Duration) (node *dht.Node, peer *PeerInfo, err error) {
|
||||
// first check if in mirrored node list
|
||||
var nodeID2 [protocol.HashSize]byte
|
||||
copy(nodeID2[:], nodeID)
|
||||
if peer, ok := nodeList[nodeID2]; ok {
|
||||
if peer = NodelistLookup(nodeID); peer != nil {
|
||||
return nil, peer, nil
|
||||
}
|
||||
|
||||
|
||||
11
Peer ID.go
11
Peer ID.go
@@ -204,6 +204,17 @@ func PeerlistLookup(publicKey *btcec.PublicKey) (peer *PeerInfo) {
|
||||
return peerList[publicKey2Compressed(publicKey)]
|
||||
}
|
||||
|
||||
// NodelistLookup returns the peer from the list with the node ID
|
||||
func NodelistLookup(nodeID []byte) (peer *PeerInfo) {
|
||||
peerlistMutex.RLock()
|
||||
defer peerlistMutex.RUnlock()
|
||||
|
||||
var nodeID2 [protocol.HashSize]byte
|
||||
copy(nodeID2[:], nodeID)
|
||||
|
||||
return nodeList[nodeID2]
|
||||
}
|
||||
|
||||
// PeerlistCount returns the current count of peers in the peer list
|
||||
func PeerlistCount() (count int) {
|
||||
peerlistMutex.RLock()
|
||||
|
||||
Reference in New Issue
Block a user