NodelistLookup function

This commit is contained in:
Kleissner
2021-12-14 02:05:08 +01:00
parent ced9574e5e
commit 281622aa49
2 changed files with 12 additions and 3 deletions

View File

@@ -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()