Moving work_v1::value function on to work_thresholds where it belongs.
This commit is contained in:
parent
442fb1eaba
commit
aef5020818
4 changed files with 24 additions and 27 deletions
|
@ -88,6 +88,26 @@ uint64_t nano::work_thresholds::value (nano::root const & root_a, uint64_t work_
|
|||
}
|
||||
#endif
|
||||
|
||||
uint64_t nano::work_thresholds::threshold (nano::block_details const & details_a)
|
||||
{
|
||||
static_assert (nano::epoch::max == nano::epoch::epoch_2, "work_v1::threshold is ill-defined");
|
||||
|
||||
uint64_t result{ std::numeric_limits<uint64_t>::max () };
|
||||
switch (details_a.epoch)
|
||||
{
|
||||
case nano::epoch::epoch_2:
|
||||
result = (details_a.is_receive || details_a.is_epoch) ? epoch_2_receive : epoch_2;
|
||||
break;
|
||||
case nano::epoch::epoch_1:
|
||||
case nano::epoch::epoch_0:
|
||||
result = epoch_1;
|
||||
break;
|
||||
default:
|
||||
debug_assert (false && "Invalid epoch specified to work_v1 ledger work_threshold");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
namespace nano
|
||||
{
|
||||
const char * network_constants::active_network_err_msg = "Invalid network. Valid values are live, test, beta and dev.";
|
||||
|
|
|
@ -83,6 +83,7 @@ enum class work_version
|
|||
};
|
||||
enum class block_type : uint8_t;
|
||||
class root;
|
||||
class block_details;
|
||||
|
||||
class work_thresholds
|
||||
{
|
||||
|
@ -111,6 +112,7 @@ public:
|
|||
|
||||
uint64_t threshold_entry (nano::work_version const, nano::block_type const);
|
||||
uint64_t value (nano::root const & root_a, uint64_t work_a);
|
||||
uint64_t threshold (nano::block_details const &);
|
||||
|
||||
/** Network work thresholds. Define these inline as constexpr when moving to cpp17. */
|
||||
static const nano::work_thresholds publish_full;
|
||||
|
|
|
@ -66,11 +66,12 @@ uint64_t nano::work_threshold_base (nano::work_version const version_a)
|
|||
|
||||
uint64_t nano::work_threshold (nano::work_version const version_a, nano::block_details const details_a)
|
||||
{
|
||||
static nano::network_constants network_constants;
|
||||
uint64_t result{ std::numeric_limits<uint64_t>::max () };
|
||||
switch (version_a)
|
||||
{
|
||||
case nano::work_version::work_1:
|
||||
result = nano::work_v1::threshold (details_a);
|
||||
result = network_constants.publish_thresholds.threshold (details_a);
|
||||
break;
|
||||
default:
|
||||
debug_assert (false && "Invalid version specified to ledger work_threshold");
|
||||
|
@ -78,27 +79,6 @@ uint64_t nano::work_threshold (nano::work_version const version_a, nano::block_d
|
|||
return result;
|
||||
}
|
||||
|
||||
uint64_t nano::work_v1::threshold (nano::block_details const details_a)
|
||||
{
|
||||
static_assert (nano::epoch::max == nano::epoch::epoch_2, "work_v1::threshold is ill-defined");
|
||||
static nano::network_constants network_constants;
|
||||
|
||||
uint64_t result{ std::numeric_limits<uint64_t>::max () };
|
||||
switch (details_a.epoch)
|
||||
{
|
||||
case nano::epoch::epoch_2:
|
||||
result = (details_a.is_receive || details_a.is_epoch) ? network_constants.publish_thresholds.epoch_2_receive : network_constants.publish_thresholds.epoch_2;
|
||||
break;
|
||||
case nano::epoch::epoch_1:
|
||||
case nano::epoch::epoch_0:
|
||||
result = network_constants.publish_thresholds.epoch_1;
|
||||
break;
|
||||
default:
|
||||
debug_assert (false && "Invalid epoch specified to work_v1 ledger work_threshold");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
double nano::normalized_multiplier (double const multiplier_a, uint64_t const threshold_a)
|
||||
{
|
||||
static nano::network_constants network_constants;
|
||||
|
|
|
@ -27,11 +27,6 @@ uint64_t work_threshold_base (nano::work_version const);
|
|||
// Ledger threshold
|
||||
uint64_t work_threshold (nano::work_version const, nano::block_details const);
|
||||
|
||||
namespace work_v1
|
||||
{
|
||||
uint64_t threshold (nano::block_details const);
|
||||
}
|
||||
|
||||
double normalized_multiplier (double const, uint64_t const);
|
||||
double denormalized_multiplier (double const, uint64_t const);
|
||||
class opencl_work;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue