src/scp/LocalNode.cpp
uint64
LocalNode::getNodeWeight(NodeID const& nodeID, SCPQuorumSet const& qset)
{
    uint64 n = qset.threshold;
    uint64 d = qset.innerSets.size() + qset.validators.size();
    uint64 res;

    for (auto const& qsetNode : qset.validators)
    {
        if (qsetNode == nodeID)
        {
            bigDivide(res, UINT64_MAX, n, d, ROUND_DOWN);
            return res;
        }
    }

    for (auto const& q : qset.innerSets)
    {
        uint64 leafW = getNodeWeight(nodeID, q);
        if (leafW)
        {
            bigDivide(res, leafW, n, d, ROUND_DOWN);
            return res;
        }
    }

    return 0;
}
// if a validator is repeated multiple times its weight is only the
// weight of the first occurrence
if a validator is repeated multiple times its weight is only the
weight of the first occurrence
if a validator is repeated multiple times its weight is only the weight of the first occurrence
uint64
LocalNode::getNodeWeight(NodeID const& nodeID, SCPQuorumSet const& qset)
{
    uint64 n = qset.threshold;
    uint64 d = qset.innerSets.size() + qset.validators.size();
    uint64 res;
    for (auto const& qsetNode : qset.validators)
    {
        if (qsetNode == nodeID)
        {
            bigDivide(res, UINT64_MAX, n, d, ROUND_DOWN);
            return res;
        }
    }
    for (auto const& q : qset.innerSets)
    {
        uint64 leafW = getNodeWeight(nodeID, q);
        if (leafW)
        {
            bigDivide(res, leafW, n, d, ROUND_DOWN);
            return res;
        }
    }
    return 0;
}
uint64 LocalNode :: getNodeWeight ( NodeID const & nodeID , SCPQuorumSet const & qset ) { uint64 n = qset . threshold ; uint64 d = qset . innerSets . size ( ) + qset . validators . size ( ) ; uint64 res ; for ( auto const & qsetNode : qset . validators ) { if ( qsetNode == nodeID ) { bigDivide ( res , UINT64_MAX , n , d , ROUND_DOWN ) ; return res ; } } for ( auto const & q : qset . innerSets ) { uint64 leafW = getNodeWeight ( nodeID , q ) ; if ( leafW ) { bigDivide ( res , leafW , n , d , ROUND_DOWN ) ; return res ; } } return 0 ; }
if a validator is repeated multiple times its weight is only the
weight of the first occurrence
if a validator is repeated multiple times its weight is only the weight of the first occurrence