Skip to content

Commit

Permalink
Fix bug where node doesn't have a bucket when we try to mark it as un…
Browse files Browse the repository at this point in the history
…successful.

Annotate what node dictionaries represent.
  • Loading branch information
derekpierre committed Aug 9, 2024
1 parent bd537c6 commit 78f0d93
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions porter/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,10 @@ def __init__(self, _reservoir, need_successes: int):
self.reservoir = _reservoir
self.need_successes = need_successes
self.predefined_buckets = self.read_buckets()
self.bucketed_nodes = defaultdict(list)
self.selected_nodes = dict()
self.bucketed_nodes = defaultdict(
list
) # <bucket> -> <list of checksum addresses>
self.selected_nodes = dict() # <checksum address> -> <bucket>

def read_buckets(self) -> Dict:
try:
Expand All @@ -420,9 +422,10 @@ def find_bucket(self, node):
return bucket_name
return None

def mark_as_not_successful(self, failure: ChecksumAddress):
bucket = self.selected_nodes[failure]
self.bucketed_nodes[bucket].remove(failure)
def mark_as_not_successful(self, unsuccessful_node: ChecksumAddress):
bucket = self.selected_nodes.get(unsuccessful_node)
if bucket:
self.bucketed_nodes[bucket].remove(unsuccessful_node)

def __call__(self, _successes: int) -> Optional[List[ChecksumAddress]]:
batch = []
Expand Down

0 comments on commit 78f0d93

Please sign in to comment.