mirror of
https://github.com/pyMC-dev/pyMC_Repeater.git
synced 2026-08-07 09:23:06 +02:00
refactor(router): centralize bridge fan-out and type drop reasons
Replace the eight hand-rolled companion-bridge delivery loops in the packet router with a single _fan_out_to_bridges helper that reads HandlerResult.authenticated directly, so a broken handler contract surfaces instead of being hidden by getattr hedges. Introduce a DropReason str-Enum in the engine for the seventeen fixed drop reasons (with __str__ returning the value, since str() of a str-Enum changed on Python 3.11+) and derive the router's expected-drop check from it, retiring the string-prefix tuple. Detailed variants keep their suffixes embedded in the reason string. Split the companion-delivery dedupe cache into a pure check and an explicit mark so PATH and protocol responses record delivery only after the fan-out runs — a copy where every bridge raised is retried on the next copy instead of being suppressed for the full TTL.
This commit is contained in:
@@ -15,6 +15,8 @@ from typing import Dict, Optional, Tuple
|
||||
|
||||
from openhop_core.node.handlers.advert import AdvertHandler
|
||||
|
||||
from repeater.engine import DropReason
|
||||
|
||||
logger = logging.getLogger("AdvertHelper")
|
||||
|
||||
|
||||
@@ -551,7 +553,7 @@ class AdvertHelper:
|
||||
if not advert_data or not advert_data.get("valid"):
|
||||
logger.warning("Invalid advert packet received, dropping.")
|
||||
packet.mark_do_not_retransmit()
|
||||
packet.drop_reason = "Invalid advert packet"
|
||||
packet.drop_reason = DropReason.INVALID_ADVERT
|
||||
return
|
||||
|
||||
# Extract data from parsed advert
|
||||
|
||||
Reference in New Issue
Block a user