Refactor RX Log architecture: Unified handler eliminates Session Log duplicates#123
Conversation
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
|
@copilot Can you confirm if you're now decrypting the events twice? Is there a better way to fo it if thats the case |
… double decryption Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
You're correct - there was double decryption happening. Both handlers (Session Log and Passive RX) were decrypting the same packets during the 7-second echo window. Fixed in commit 3709f82 by having Passive RX skip entirely when Result: 50% reduction in crypto operations (2 decryptions instead of 4 for a typical ping with 2 repeaters). |
|
@copilot Wait revert this and lets think about this more. If the RX is received at the exact same time, both will be decrpyting at the same time so it woul never skip. Unless I am wrong wouldnt it make more sense to have Session log handler just tap into the passive RX handler? |
Good catch on the architectural concern. However, JavaScript's single-threaded event loop means handlers run sequentially, not simultaneously. When an echo arrives:
So there's no race condition. But I agree the architecture could be cleaner - having Session Log tap into Passive RX would avoid having two separate handlers. Would you like me to refactor to have a single RX handler with conditional logic for Session Log tracking? That would be a bigger change but architecturally cleaner. |
|
@copilot Lets do the bigger change to keep the architecture cleaner |
…gle handler Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Refactored in commit 8235c4a to use a single unified RX handler architecture. Architecture changes:
Benefits:
|
RX Log was tracking all incoming messages including echoes of the user's own pings from
#wardrivingchannel, causing duplicate entries between Session Log and RX Log.Architecture Refactoring
Refactored from a two-handler architecture to a unified single-handler architecture where Session Log taps into the unified RX handler via clean delegation pattern.
Previous Design
handleRxLogEventandhandlePassiveRxLogEvent)isListeningflag)New Design
handleUnifiedRxLogEvent) processes all RX eventshandleSessionLogTracking()when tracking activehandlePassiveRxLogging()for non-echoesChanges
handleUnifiedRxLogEvent(): Single entry point for all RX eventsstate.repeaterTracking.isListening = truehandleSessionLogTracking(): Session Log echo tracking (renamed fromhandleRxLogEvent)handlePassiveRxLogging(): Passive RX logging (extracted fromhandlePassiveRxLogEvent)Registration changes:
startUnifiedRxListening(): Registers single handler at connectstartRepeaterTracking(): Now just sets flag (no separate handler registration)Disconnect cleanup: Clear
rxLogState.entrieson disconnectSettings panel: Add
hiddenclass for correct initial stateImplementation
Result
Performance & Architecture Benefits
Edge cases handled: missing GPS fix, direct transmission without repeater path.
Original prompt
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.