Skip to content

Commit

Permalink
Refactor validator.py to remove duplicate entries in penalized_hotkey…
Browse files Browse the repository at this point in the history
…s_checklist
  • Loading branch information
mo0haned committed Sep 18, 2024
1 parent 6739056 commit 6202bd4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions neurons/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,21 @@ def sync_status(self):
current_version = __version_as_int__
if subnet_prometheus_version != current_version:
self.init_prometheus(force_update=True)
def remove_duplicate_penalized_hotkeys(self):
"""
Removes any duplicate entries in the penalized_hotkeys_checklist
based on the 'hotkey' field.
"""
seen = set()
unique_penalized_list = []

for item in self.penalized_hotkeys_checklist:
if item['hotkey'] not in seen:
unique_penalized_list.append(item)
seen.add(item['hotkey'])

self.penalized_hotkeys_checklist = unique_penalized_list
bt.logging.info("Removed duplicate hotkeys from penalized_hotkeys_checklist.")

def sync_checklist(self):
self.threads = []
Expand All @@ -374,6 +389,7 @@ def sync_checklist(self):
)
except KeyError:
continue
self.remove_duplicate_penalized_hotkeys()

for thread in self.threads:
thread.start()
Expand Down

0 comments on commit 6202bd4

Please sign in to comment.