Skip to content

Commit

Permalink
Fix LMD ghost tie-breaking
Browse files Browse the repository at this point in the history
  • Loading branch information
yudetamago committed Apr 8, 2019
1 parent b8b333c commit 36ffe24
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cbc_casper_simulator/estimator/lmd_ghost_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ def estimate(cls, state: State, justification: Justification) -> Block:
store: Store = state.store

best_block = store.genesis_block()

while store.has_children_blocks(best_block):
# If "tie" exists, choose the block with the smallest hash.
best_block = max(store.children_blocks(
best_block), key=lambda x: scores.get(x, 0))
best_block), key=lambda block: (scores.get(block, 0), -block.hash))
return Block(best_block.hash)

@classmethod
Expand Down

0 comments on commit 36ffe24

Please sign in to comment.