fix(ble): Clean up address_to_identity in _cleanup_stale_interface()

The _cleanup_stale_interface() method was cleaning up identity_to_address
but not the reverse mapping address_to_identity. This caused:
- Memory leak: stale entries accumulate over time
- Inconsistent state: bidirectional mappings become out of sync

This fix matches the cleanup pattern in _disconnected_callback() which
properly cleans up both directions of the mapping.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
torlando-tech 2025-12-27 23:47:17 -05:00
commit 0c80f4f100

View file

@ -1036,9 +1036,11 @@ class BLEInterface(Interface):
old_interface.detach()
RNS.log(f"{self} detached stale interface for {identity_hash[:8]}", RNS.LOG_DEBUG)
# Clean up address mappings
# Clean up address mappings (both directions)
if identity_hash in self.identity_to_address:
del self.identity_to_address[identity_hash]
if old_address in self.address_to_identity:
del self.address_to_identity[old_address]
# Clean up fragmenter/reassembler for old address
if peer_identity: