forked from LBRYCommunity/lbry-sdk
use PingQueue to try refresh all contacts
This commit is contained in:
parent
9920ff59d4
commit
4f72098cad
|
@ -650,14 +650,19 @@ class Node(MockKademliaHelper):
|
||||||
def _refreshNode(self):
|
def _refreshNode(self):
|
||||||
""" Periodically called to perform k-bucket refreshes and data
|
""" Periodically called to perform k-bucket refreshes and data
|
||||||
replication/republishing as necessary """
|
replication/republishing as necessary """
|
||||||
|
|
||||||
yield self._refreshRoutingTable()
|
yield self._refreshRoutingTable()
|
||||||
self._dataStore.removeExpiredPeers()
|
self._dataStore.removeExpiredPeers()
|
||||||
defer.returnValue(None)
|
defer.returnValue(None)
|
||||||
|
|
||||||
|
def _refreshContacts(self):
|
||||||
|
return defer.DeferredList(
|
||||||
|
[self._protocol._ping_queue.enqueue_maybe_ping(contact) for contact in self.contacts]
|
||||||
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _refreshRoutingTable(self):
|
def _refreshRoutingTable(self):
|
||||||
nodeIDs = self._routingTable.getRefreshList(0, True)
|
nodeIDs = self._routingTable.getRefreshList(0, True)
|
||||||
|
yield self._refreshContacts()
|
||||||
while nodeIDs:
|
while nodeIDs:
|
||||||
searchID = nodeIDs.pop()
|
searchID = nodeIDs.pop()
|
||||||
yield self.iterativeFindNode(searchID)
|
yield self.iterativeFindNode(searchID)
|
||||||
|
|
|
@ -85,6 +85,7 @@ class PingQueue(object):
|
||||||
def enqueue_maybe_ping(self, contact):
|
def enqueue_maybe_ping(self, contact):
|
||||||
return self._semaphore.run(self._add_contact, contact)
|
return self._semaphore.run(self._add_contact, contact)
|
||||||
|
|
||||||
|
|
||||||
class KademliaProtocol(protocol.DatagramProtocol):
|
class KademliaProtocol(protocol.DatagramProtocol):
|
||||||
""" Implements all low-level network-related functions of a Kademlia node """
|
""" Implements all low-level network-related functions of a Kademlia node """
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue