Merge pull request #5510

e9809382 fix wide difficulty conversion with some versions of boost (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2019-05-07 17:36:27 +02:00
commit f64f59627d
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD
11 changed files with 25 additions and 25 deletions

View file

@ -124,7 +124,7 @@ int main(int argc, char *argv[]) {
cryptonote::difficulty_type wide_res = cryptonote::next_difficulty(
std::vector<uint64_t>(timestamps.begin() + begin, timestamps.begin() + end),
std::vector<cryptonote::difficulty_type>(wide_cumulative_difficulties.begin() + begin, wide_cumulative_difficulties.begin() + end), DEFAULT_TEST_DIFFICULTY_TARGET);
if (wide_res.convert_to<uint64_t>() != res) {
if ((wide_res & 0xffffffffffffffff).convert_to<uint64_t>() != res) {
cerr << "Wrong wide difficulty for block " << n << endl
<< "Expected: " << res << endl
<< "Found: " << wide_res << endl;

View file

@ -61,7 +61,7 @@ int main(int argc, char *argv[]) {
for (int i = 31; i >= 0; i--) {
val = val * 256 + 255;
((char *) &h)[i] = static_cast<char>(static_cast<uint64_t>(val / diff));
val %= diff.convert_to<uint64_t>();
val %= (diff & 0xffffffffffffffff).convert_to<uint64_t>();
}
if (check_hash(h, diff) != true) {
return 3;

View file

@ -44,13 +44,13 @@ public:
difficulty = difficulty_high;
difficulty = (difficulty << 64) | difficulty_low;
boost::multiprecision::uint256_t hash_value = std::numeric_limits<boost::multiprecision::uint256_t>::max() / hash_target;
((uint64_t*)&hash)[0] = (hash_value << 64 >> 64).convert_to<uint64_t>();
((uint64_t*)&hash)[0] = (hash_value & 0xffffffffffffffff).convert_to<uint64_t>();
hash_value >>= 64;
((uint64_t*)&hash)[1] = (hash_value << 64 >> 64).convert_to<uint64_t>();
((uint64_t*)&hash)[1] = (hash_value & 0xffffffffffffffff).convert_to<uint64_t>();
hash_value >>= 64;
((uint64_t*)&hash)[2] = (hash_value << 64 >> 64).convert_to<uint64_t>();
((uint64_t*)&hash)[2] = (hash_value & 0xffffffffffffffff).convert_to<uint64_t>();
hash_value >>= 64;
((uint64_t*)&hash)[3] = (hash_value << 64 >> 64).convert_to<uint64_t>();
((uint64_t*)&hash)[3] = (hash_value & 0xffffffffffffffff).convert_to<uint64_t>();
return true;
}

View file

@ -42,13 +42,13 @@ static crypto::hash MKHASH(uint64_t high, uint64_t low)
hash_target = (hash_target << 64) | low;
boost::multiprecision::uint256_t hash_value = std::numeric_limits<boost::multiprecision::uint256_t>::max() / hash_target;
crypto::hash h;
((uint64_t*)&h)[0] = hash_value.convert_to<uint64_t>();
((uint64_t*)&h)[0] = (hash_value & 0xffffffffffffffff).convert_to<uint64_t>();
hash_value >>= 64;
((uint64_t*)&h)[1] = hash_value.convert_to<uint64_t>();
((uint64_t*)&h)[1] = (hash_value & 0xffffffffffffffff).convert_to<uint64_t>();
hash_value >>= 64;
((uint64_t*)&h)[2] = hash_value.convert_to<uint64_t>();
((uint64_t*)&h)[2] = (hash_value & 0xffffffffffffffff).convert_to<uint64_t>();
hash_value >>= 64;
((uint64_t*)&h)[3] = hash_value.convert_to<uint64_t>();
((uint64_t*)&h)[3] = (hash_value & 0xffffffffffffffff).convert_to<uint64_t>();
return h;
}