mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-11-02 10:41:59 +00:00
send_msg_with_retries: now fetches contacts before resetting path
This commit is contained in:
@@ -131,18 +131,21 @@ class MessagingCommands(CommandHandlerBase):
|
|||||||
while attempts < max_attempts and res is None \
|
while attempts < max_attempts and res is None \
|
||||||
and (not flood or flood_attempts < max_flood_attempts):
|
and (not flood or flood_attempts < max_flood_attempts):
|
||||||
if attempts == flood_after and not flood : # change path to flood
|
if attempts == flood_after and not flood : # change path to flood
|
||||||
if len(dst_bytes) == 32: # can only reset with full key
|
if len(dst_bytes) < 32: # can only reset with full key
|
||||||
logger.info("Resetting path")
|
logger.info("Don't have full key, retreiving contacts so we can reset path")
|
||||||
rp_res = await self.reset_path(dst_bytes)
|
await self.get_contacts()
|
||||||
if rp_res.type == EventType.ERROR:
|
contact = self._get_contact_by_prefix(dst_bytes.hex())
|
||||||
logger.error(f"Couldn't reset path {rp_res} continuing ...")
|
if not contact is None:
|
||||||
else:
|
dst_bytes = _validate_destination(contact, prefix_length=32)
|
||||||
flood = True
|
logger.info("Resetting path")
|
||||||
if not contact is None:
|
rp_res = await self.reset_path(dst_bytes)
|
||||||
contact["out_path"] = ""
|
if rp_res.type == EventType.ERROR:
|
||||||
contact["out_path_len"] = -1
|
logger.error(f"Couldn't reset path {rp_res} continuing ...")
|
||||||
else:
|
else:
|
||||||
logger.info("Don't have full key, can't reset path")
|
flood = True
|
||||||
|
if not contact is None:
|
||||||
|
contact["out_path"] = ""
|
||||||
|
contact["out_path_len"] = -1
|
||||||
|
|
||||||
if attempts > 0:
|
if attempts > 0:
|
||||||
logger.info(f"Retry sending msg: {attempts + 1}")
|
logger.info(f"Retry sending msg: {attempts + 1}")
|
||||||
|
|||||||
Reference in New Issue
Block a user