mirror of
https://github.com/PeernetOfficial/core.git
synced 2026-07-16 18:37:51 +01:00
contactArbitraryPeer only if not already in peer list.
Remove nodes from Kademlia structure when appropriate.
This commit is contained in:
@@ -195,6 +195,11 @@ func autoMulticastBroadcast() {
|
||||
}
|
||||
|
||||
func contactArbitraryPeer(publicKey *btcec.PublicKey, ip net.IP, port uint16) {
|
||||
// check first if peer is already in the list!
|
||||
if peer := PeerlistLookup(publicKey); peer != nil {
|
||||
return
|
||||
}
|
||||
|
||||
packets, err := msgEncodeAnnouncement(true, true, nil, nil, nil)
|
||||
if len(packets) == 0 || err != nil {
|
||||
return
|
||||
|
||||
@@ -112,6 +112,9 @@ func PeerlistRemove(peer *PeerInfo) {
|
||||
peerlistMutex.Lock()
|
||||
defer peerlistMutex.Unlock()
|
||||
|
||||
// remove from Kademlia
|
||||
nodesDHT.RemoveNode(peer.NodeID)
|
||||
|
||||
delete(peerList, publicKey2Compressed(peer.PublicKey))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user