improve store_to_peer retry, reduce error verbosity
This commit is contained in:
parent
43b83bec83
commit
f99aacd9dc
1 changed files with 12 additions and 12 deletions
|
@ -532,7 +532,7 @@ class KademliaProtocol(DatagramProtocol):
|
||||||
elif error_datagram.response not in old_protocol_errors:
|
elif error_datagram.response not in old_protocol_errors:
|
||||||
log.warning(error_msg)
|
log.warning(error_msg)
|
||||||
else:
|
else:
|
||||||
log.warning("known dht protocol backwards compatibility error with %s:%i (lbrynet v%s)",
|
log.debug("known dht protocol backwards compatibility error with %s:%i (lbrynet v%s)",
|
||||||
peer.address, peer.udp_port, old_protocol_errors[error_datagram.response])
|
peer.address, peer.udp_port, old_protocol_errors[error_datagram.response])
|
||||||
df.set_exception(remote_exception)
|
df.set_exception(remote_exception)
|
||||||
return
|
return
|
||||||
|
@ -542,7 +542,7 @@ class KademliaProtocol(DatagramProtocol):
|
||||||
f"pending request: {str(remote_exception)}"
|
f"pending request: {str(remote_exception)}"
|
||||||
log.warning(msg)
|
log.warning(msg)
|
||||||
else:
|
else:
|
||||||
log.warning("known dht protocol backwards compatibility error with %s:%i (lbrynet v%s)",
|
log.debug("known dht protocol backwards compatibility error with %s:%i (lbrynet v%s)",
|
||||||
address[0], address[1], old_protocol_errors[error_datagram.response])
|
address[0], address[1], old_protocol_errors[error_datagram.response])
|
||||||
|
|
||||||
def datagram_received(self, datagram: bytes, address: typing.Tuple[str, int]) -> None:
|
def datagram_received(self, datagram: bytes, address: typing.Tuple[str, int]) -> None:
|
||||||
|
@ -646,7 +646,8 @@ class KademliaProtocol(DatagramProtocol):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
async def store_to_peer(self, hash_value: bytes, peer: 'KademliaPeer') -> typing.Tuple[bytes, bool]:
|
async def store_to_peer(self, hash_value: bytes, peer: 'KademliaPeer',
|
||||||
|
retry: bool = True) -> typing.Tuple[bytes, bool]:
|
||||||
async def __store():
|
async def __store():
|
||||||
res = await self.get_rpc_peer(peer).store(hash_value)
|
res = await self.get_rpc_peer(peer).store(hash_value)
|
||||||
if res != b"OK":
|
if res != b"OK":
|
||||||
|
@ -658,16 +659,15 @@ class KademliaProtocol(DatagramProtocol):
|
||||||
return await __store()
|
return await __store()
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
log.debug("Timeout while storing blob_hash %s at %s", binascii.hexlify(hash_value).decode()[:8], peer)
|
log.debug("Timeout while storing blob_hash %s at %s", binascii.hexlify(hash_value).decode()[:8], peer)
|
||||||
|
return peer.node_id, False
|
||||||
except ValueError as err:
|
except ValueError as err:
|
||||||
log.error("Unexpected response: %s" % err)
|
log.error("Unexpected response: %s" % err)
|
||||||
|
return peer.node_id, False
|
||||||
except RemoteException as err:
|
except RemoteException as err:
|
||||||
if 'Invalid token' in str(err):
|
if 'Invalid token' not in str(err):
|
||||||
self.peer_manager.clear_token(peer.node_id)
|
|
||||||
try:
|
|
||||||
return await __store()
|
|
||||||
except (ValueError, asyncio.TimeoutError, RemoteException):
|
|
||||||
return peer.node_id, False
|
|
||||||
else:
|
|
||||||
log.exception("Unexpected error while storing blob_hash")
|
log.exception("Unexpected error while storing blob_hash")
|
||||||
return peer.node_id, False
|
return peer.node_id, False
|
||||||
|
self.peer_manager.clear_token(peer.node_id)
|
||||||
|
if not retry:
|
||||||
|
return peer.node_id, False
|
||||||
|
return await self.store_to_peer(hash_value, peer, retry=False)
|
||||||
|
|
Loading…
Add table
Reference in a new issue