def get_majority_vote_in_set_for_event(hashgraph, s: Set[str], x: Event) -> (bool, int):
"""
Returns the majority vote and the winning amount of stake that a set of witnesses has for another event
:param hashgraph:
:param s:
:param x:
:return: Tuple containing the majority vote (bool) and the total stake of the majority vote (int)
"""
stake_for = 0
stake_against = 0
for event_id in s:
event = hashgraph.lookup_table[event_id]
if x.id in event.votes and event.votes[x.id]:
stake_for += hashgraph.known_members[event.verify_key].stake
else:
stake_against += hashgraph.known_members[event.verify_key].stake
return Fame.TRUE if stake_for >= stake_against else Fame.FALSE, stake_for if stake_for >= stake_against else stake_against
评论列表
文章目录