Stats API: local_hash should respect path_hash_mode #53

Closed
opened 2026-10-27 09:30:25 +01:00 by adam · 2 comments
Owner

Summary

The /api/stats response always returns a 1-byte local_hash (0x19) regardless of the configured path_hash_mode.

Current behavior

engine.py line ~975 (feat/companion):

"local_hash": f"0x{self.local_hash:02x}",

self.local_hash is set in main.py line 127 as pubkey[0] — always the first byte. The 3-byte local_hash_bytes = pubkey[:3] exists (line 128) but is never used in the stats response.

Same pattern for identity hashes throughout api_endpoints.py — all use get_public_key()[0] with 02X formatting.

Requested change

When config.mesh.path_hash_mode is 1 (2-byte) or 2 (3-byte), format local_hash using the corresponding width from local_hash_bytes:

  • Mode 0: 0x19 (1-byte, current behavior)
  • Mode 1: 0x1927 (2-byte)
  • Mode 2: 0x192722 (3-byte)

Same for identity hashes in /api/identities, /api/acl_clients, /api/room_clients, etc.

## Summary The `/api/stats` response always returns a 1-byte `local_hash` (`0x19`) regardless of the configured `path_hash_mode`. ## Current behavior `engine.py` line ~975 (`feat/companion`): ```python "local_hash": f"0x{self.local_hash:02x}", ``` `self.local_hash` is set in `main.py` line 127 as `pubkey[0]` — always the first byte. The 3-byte `local_hash_bytes = pubkey[:3]` exists (line 128) but is never used in the stats response. Same pattern for identity hashes throughout `api_endpoints.py` — all use `get_public_key()[0]` with `02X` formatting. ## Requested change When `config.mesh.path_hash_mode` is `1` (2-byte) or `2` (3-byte), format `local_hash` using the corresponding width from `local_hash_bytes`: - Mode 0: `0x19` (1-byte, current behavior) - Mode 1: `0x1927` (2-byte) - Mode 2: `0x192722` (3-byte) Same for identity hashes in `/api/identities`, `/api/acl_clients`, `/api/room_clients`, etc. <!-- github-sync-id:4050461200 -->
adam closed this issue 2026-10-27 09:30:25 +01:00
Author
Owner

I have add this with commit 155575865a

I have add this with commit 155575865af14108a5b53d0d27d7ed24c53a058f <!-- github-comment-id:4039867078 -->
Author
Owner

fixed!

fixed! <!-- github-comment-id:4040785417 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/pyMC_Repeater#53