Skip to content

Commit

Permalink
Set rounding mode explicitly where we need it
Browse files Browse the repository at this point in the history
Instead of implicitly relying on the mode we expect it to be
  • Loading branch information
Doy-lee committed Oct 9, 2019
1 parent d39a144 commit 049c2e8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/cryptonote_basic/cryptonote_basic_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ namespace cryptonote {

uint64_t block_reward_unpenalized_formula_v8(uint64_t height)
{
std::fesetround(FE_TONEAREST);
uint64_t result = 28000000000.0 + 100000000000.0 / loki::exp2(height / (720.0 * 90.0)); // halve every 90 days.
return result;
}
Expand Down
6 changes: 1 addition & 5 deletions src/cryptonote_core/cryptonote_tx_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ using namespace epee;
#include "ringct/rctSigs.h"
#include "multisig/multisig.h"
#include "int-util.h"
#include <cfenv>

using namespace crypto;

Expand Down Expand Up @@ -982,7 +981,6 @@ namespace cryptonote
{
blobdata bd = get_block_hashing_blob(b);
rx_slow_hash(main_height, seed_height, seed_hash.data, bd.data(), bd.size(), res.data, 0, 1);
std::fesetround(FE_TONEAREST);
}

bool get_block_longhash(const Blockchain *pbc, const block& b, crypto::hash& res, const uint64_t height, const int miners)
Expand All @@ -995,8 +993,7 @@ namespace cryptonote
const_cast<int &>(miners) = 0;
#endif

if (hf_version >= network_version_12_checkpointing)
{
if (hf_version >= network_version_12_checkpointing) {
uint64_t seed_height, main_height;
crypto::hash hash;
if (pbc != NULL)
Expand All @@ -1011,7 +1008,6 @@ namespace cryptonote
main_height = 0;
}
rx_slow_hash(main_height, seed_height, hash.data, bd.data(), bd.size(), res.data, miners, 0);
std::fesetround(FE_TONEAREST);
return true;
}

Expand Down
1 change: 1 addition & 0 deletions src/cryptonote_core/service_node_rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ uint64_t get_staking_requirement(cryptonote::network_type m_nettype, uint64_t he

uint64_t height_adjusted = height - hardfork_height;
uint64_t base = 0, variable = 0;
std::fesetround(FE_TONEAREST);
if (hf_version >= cryptonote::network_version_11_infinite_staking)
{
base = 15000 * COIN;
Expand Down

0 comments on commit 049c2e8

Please sign in to comment.