8 #include <boost/range/adaptors.hpp> 9 #include <boost/range/numeric.hpp> 16 double float_point_ratio = double(ratio.first) / ratio.second;
18 using boost::adaptors::transformed;
19 double theta = double(authorities[authority_index].weight)
21 authorities | transformed([](
const auto &authority) {
22 return authority.weight;
26 using namespace boost::multiprecision;
27 cpp_rational p_rat(1. - pow(1. - float_point_ratio, theta));
28 static const auto a = (
uint256_t{1} << 128);
29 return Threshold{a * numerator(p_rat) / denominator(p_rat)};
boost::multiprecision::uint256_t uint256_t
Threshold calculateThreshold(const std::pair< uint64_t, uint64_t > &ratio, const primitives::AuthorityList &authorities, primitives::AuthorityIndex authority_index)
crypto::VRFThreshold Threshold
threshold, which must not be exceeded for the party to be a slot leader