consensus.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:bptc_wallet 作者: ceddie 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号