Skip to content

Commit

Permalink
Merge pull request #49 from LayerXcom/lmd_ghost_tie_breaking
Browse files Browse the repository at this point in the history
Fix LMD ghost tie-breaking
  • Loading branch information
yudetamago authored Apr 8, 2019
2 parents b8b333c + 36ffe24 commit de186bd
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 de186bd

Please sign in to comment.