Skip to content

Commit

Permalink
Pretest for updating connection time.
Browse files Browse the repository at this point in the history
  • Loading branch information
fchirica authored and hoffmang9 committed Jan 13, 2021
1 parent daf1c9d commit 99b4a10
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/server/node_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def __init__(
self.log = log
self.relay_queue = None
self.address_manager = None
self.connection_time_pretest = {}

async def initialize_address_manager(self):
mkdir(self.peer_db_path.parent)
Expand Down Expand Up @@ -120,7 +121,12 @@ async def update_peer_timestamp_on_message(self, peer: ws.WSChiaConnection):
and self.server._local_type is NodeType.FULL_NODE
and self.address_manager is not None
):
await self.address_manager.connect(peer.get_peer_info())
peer_info = peer.get_peer_info()
if peer_info.host not in self.connection_time_pretest:
self.connection_time_pretest[peer_info.host] = time.time()
if time.time() - self.connection_time_pretest[peer_info.host] > 600:
self.connection_time_pretest[peer_info.host] = time.time()
await self.address_manager.connect(peer_info)

def _num_needed_peers(self) -> int:
diff = self.target_outbound_count
Expand Down

0 comments on commit 99b4a10

Please sign in to comment.