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