streamline processing in TraceHelper and PacketRouter

This commit is contained in:
Lloyd
2025-12-01 23:39:22 +00:00
parent 6c7e92d35c
commit fa0261d2a2
2 changed files with 5 additions and 10 deletions
-8
View File
@@ -84,13 +84,9 @@ class TraceHelper:
if should_forward:
await self._forward_trace_packet(packet, trace_path_len)
# Packet was sent directly, but let it flow back to engine for standard logging
# The engine will see do_not_retransmit flag and won't try to send it again
else:
# This is the final destination or can't forward - just log and record
self._log_no_forward_reason(packet, trace_path, trace_path_len)
# Mark packet to not be retransmitted since we're not forwarding
packet.mark_do_not_retransmit()
except Exception as e:
logger.error(f"Error processing trace packet: {e}")
@@ -256,10 +252,6 @@ class TraceHelper:
await self.packet_injector(packet, wait_for_ack=False)
else:
logger.warning("No packet injector available - trace packet not forwarded")
# Mark as do_not_retransmit so engine won't try to send it again
# but allow it to flow back for standard packet logging
packet.mark_do_not_retransmit()
def _log_no_forward_reason(self, packet, trace_path: list, trace_path_len: int) -> None:
"""
+5 -2
View File
@@ -102,12 +102,15 @@ class PacketRouter:
2. Pass to repeater engine for all processing decisions
"""
payload_type = packet.get_payload_type()
processed_by_injection = False
# Route to specific handlers for parsing only
if payload_type == TraceHandler.payload_type():
# Process trace packet
if self.daemon.trace_helper:
await self.daemon.trace_helper.process_trace_packet(packet)
# Skip engine processing for trace packets - they're handled by trace helper
processed_by_injection = True
elif payload_type == ControlHandler.payload_type():
# Process control/discovery packet
@@ -122,8 +125,8 @@ class PacketRouter:
snr = getattr(packet, "snr", 0.0)
await self.daemon.advert_helper.process_advert_packet(packet, rssi, snr)
# Always pass to repeater engine for processing decisions and statistics
if self.daemon.repeater_handler:
# Only pass to repeater engine if not already processed by injection
if self.daemon.repeater_handler and not processed_by_injection:
metadata = {
"rssi": getattr(packet, "rssi", 0),
"snr": getattr(packet, "snr", 0.0),