Skip to content

Therefactor: extract _metagraph_hotkey_to_uid helper in commitments.py#304

Open
Tet-9 wants to merge 1 commit into
entrius:testfrom
Tet-9:fix/169-extract-metagraph-hotkey-to-uid
Open

Therefactor: extract _metagraph_hotkey_to_uid helper in commitments.py#304
Tet-9 wants to merge 1 commit into
entrius:testfrom
Tet-9:fix/169-extract-metagraph-hotkey-to-uid

Conversation

@Tet-9
Copy link
Copy Markdown

@Tet-9 Tet-9 commented May 10, 2026

Summary

read_miner_commitment and read_miner_commitments both independently
built the same {hotkey: uid} map inline:

  • commitments.py:138{metagraph.hotkeys[u]: u for u in range(metagraph.n.item())}
  • commitments.py:160 — identical expression with different loop variable

Duplicate construction means a future change to the map logic must be
applied twice, and callers could accidentally use a stale copy.

Fix

Extract _metagraph_hotkey_to_uid(metagraph) as a module-level private
helper and call it from both functions so the map is always derived
from the same snapshot in one place.

Scope

Pure refactor. No behavior change, no signature change.

Fixes #169

read_miner_commitment and read_miner_commitments both independently
built the same {hotkey: uid} map inline. Duplicate construction means
a future change to the map logic must be applied twice and callers
could accidentally use a stale copy.

Extract _metagraph_hotkey_to_uid(metagraph) and call it from both
functions so the map is always derived from the same snapshot.

Fixes entrius#169
@xiao-xiao-mao xiao-xiao-mao Bot added the refactor Restructures code without changing behavior label May 10, 2026
@igeabdulrahmanikeoluwa-str
Copy link
Copy Markdown

@anderdc , on for review 🫡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Restructures code without changing behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

read_miner_commitment and read_miner_commitments independently build hotkey_to_uid

2 participants