91 cerr <<
"Wrong arguments" << endl;
94 if (argc == 3 && strcmp(argv[1],
"--wide") == 0)
96 return test_wide_difficulty(argv[2]);
99 vector<uint64_t> timestamps, cumulative_difficulties;
100 std::vector<cryptonote::difficulty_type> wide_cumulative_difficulties;
101 fstream data(argv[1], fstream::in);
102 data.exceptions(fstream::badbit);
103 data.clear(data.rdstate());
105 uint64_t difficulty, cumulative_difficulty = 0;
108 while (data >> timestamp >> difficulty) {
118 vector<uint64_t>(timestamps.begin() + begin, timestamps.begin() + end),
120 if (
res != difficulty) {
121 cerr <<
"Wrong difficulty for block " << n << endl
122 <<
"Expected: " << difficulty << endl
123 <<
"Found: " <<
res << endl;
127 std::vector<uint64_t>(timestamps.begin() + begin, timestamps.begin() + end),
128 std::vector<cryptonote::difficulty_type>(wide_cumulative_difficulties.begin() + begin, wide_cumulative_difficulties.begin() + end),
DEFAULT_TEST_DIFFICULTY_TARGET);
129 if ((wide_res & 0xffffffffffffffff).convert_to<uint64_t>() !=
res) {
130 cerr <<
"Wrong wide difficulty for block " << n << endl
131 <<
"Expected: " <<
res << endl
132 <<
"Found: " << wide_res << endl;
135 timestamps.push_back(timestamp);
136 cumulative_difficulties.push_back(cumulative_difficulty += difficulty);
137 wide_cumulative_difficulties.push_back(wide_cumulative_difficulty += difficulty);
141 data.clear(fstream::badbit);
difficulty_type next_difficulty(std::vector< uint64_t > timestamps, std::vector< difficulty_type > cumulative_difficulties, size_t target_seconds, uint8_t version)
unsigned __int64 uint64_t
#define DEFAULT_TEST_DIFFICULTY_TARGET
boost::multiprecision::uint128_t difficulty_type
#define DEFAULT_TEST_DIFFICULTY_WINDOW
#define CATCH_ENTRY_L0(lacation, return_val)
uint64_t next_difficulty_64(std::vector< std::uint64_t > timestamps, std::vector< uint64_t > cumulative_difficulties, size_t target_seconds, uint8_t version)