dht_crawler:only count latency during findNode
This commit is contained in:
parent
5e58c2f224
commit
f077e56cec
1 changed files with 7 additions and 5 deletions
|
@ -315,19 +315,21 @@ class Crawler:
|
||||||
if key == node_id:
|
if key == node_id:
|
||||||
response = await self.node.protocol.get_rpc_peer(peer).find_node(key)
|
response = await self.node.protocol.get_rpc_peer(peer).find_node(key)
|
||||||
response = FindNodeResponse(key, response)
|
response = FindNodeResponse(key, response)
|
||||||
|
latency = time.perf_counter_ns() - req_start
|
||||||
|
self.set_latency(peer, latency)
|
||||||
else:
|
else:
|
||||||
response = await self.node.protocol.get_rpc_peer(peer).find_value(key)
|
response = await self.node.protocol.get_rpc_peer(peer).find_value(key)
|
||||||
response = FindValueResponse(key, response)
|
response = FindValueResponse(key, response)
|
||||||
await asyncio.sleep(0.05)
|
await asyncio.sleep(0.05)
|
||||||
latency = time.perf_counter_ns() - req_start
|
|
||||||
self.set_latency(peer, latency)
|
|
||||||
return response
|
return response
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
|
if key == node_id:
|
||||||
self.set_latency(peer, None)
|
self.set_latency(peer, None)
|
||||||
continue
|
continue
|
||||||
except lbry.dht.error.RemoteException as e:
|
except lbry.dht.error.RemoteException as e:
|
||||||
log.info('Peer errored: %s:%d attempt #%d - %s',
|
log.info('Peer errored: %s:%d attempt #%d - %s',
|
||||||
host, port, (attempt + 1), str(e))
|
host, port, (attempt + 1), str(e))
|
||||||
|
if key == node_id:
|
||||||
self.inc_errors(peer)
|
self.inc_errors(peer)
|
||||||
self.set_latency(peer, None)
|
self.set_latency(peer, None)
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue