Add difficulty and multiplier to CLI work generation commands (#2707)
This commit is contained in:
parent
a0233d903c
commit
7b891ab939
1 changed files with 59 additions and 16 deletions
|
|
@ -100,6 +100,7 @@ int main (int argc, char * const * argv)
|
||||||
("device", boost::program_options::value<std::string> (), "Defines <device> for OpenCL command")
|
("device", boost::program_options::value<std::string> (), "Defines <device> for OpenCL command")
|
||||||
("threads", boost::program_options::value<std::string> (), "Defines <threads> count for OpenCL command")
|
("threads", boost::program_options::value<std::string> (), "Defines <threads> count for OpenCL command")
|
||||||
("difficulty", boost::program_options::value<std::string> (), "Defines <difficulty> for OpenCL command, HEX")
|
("difficulty", boost::program_options::value<std::string> (), "Defines <difficulty> for OpenCL command, HEX")
|
||||||
|
("multiplier", boost::program_options::value<std::string> (), "Defines <multiplier> for work generation. Overrides <difficulty>")
|
||||||
("pow_sleep_interval", boost::program_options::value<std::string> (), "Defines the amount to sleep inbetween each pow calculation attempt")
|
("pow_sleep_interval", boost::program_options::value<std::string> (), "Defines the amount to sleep inbetween each pow calculation attempt")
|
||||||
("address_column", boost::program_options::value<std::string> (), "Defines which column the addresses are located, 0 indexed (check --debug_output_last_backtrace_dump output)");
|
("address_column", boost::program_options::value<std::string> (), "Defines which column the addresses are located, 0 indexed (check --debug_output_last_backtrace_dump output)");
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
@ -309,6 +310,33 @@ int main (int argc, char * const * argv)
|
||||||
{
|
{
|
||||||
nano::network_constants network_constants;
|
nano::network_constants network_constants;
|
||||||
uint64_t difficulty{ network_constants.publish_full.base };
|
uint64_t difficulty{ network_constants.publish_full.base };
|
||||||
|
auto multiplier_it = vm.find ("multiplier");
|
||||||
|
if (multiplier_it != vm.end ())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
auto multiplier (boost::lexical_cast<double> (multiplier_it->second.as<std::string> ()));
|
||||||
|
difficulty = nano::difficulty::from_multiplier (multiplier, difficulty);
|
||||||
|
}
|
||||||
|
catch (boost::bad_lexical_cast &)
|
||||||
|
{
|
||||||
|
std::cerr << "Invalid multiplier\n";
|
||||||
|
result = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto difficulty_it = vm.find ("difficulty");
|
||||||
|
if (difficulty_it != vm.end ())
|
||||||
|
{
|
||||||
|
if (nano::from_string_hex (difficulty_it->second.as<std::string> (), difficulty))
|
||||||
|
{
|
||||||
|
std::cerr << "Invalid difficulty\n";
|
||||||
|
result = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto pow_rate_limiter = std::chrono::nanoseconds (0);
|
auto pow_rate_limiter = std::chrono::nanoseconds (0);
|
||||||
auto pow_sleep_interval_it = vm.find ("pow_sleep_interval");
|
auto pow_sleep_interval_it = vm.find ("pow_sleep_interval");
|
||||||
if (pow_sleep_interval_it != vm.cend ())
|
if (pow_sleep_interval_it != vm.cend ())
|
||||||
|
|
@ -318,8 +346,10 @@ int main (int argc, char * const * argv)
|
||||||
|
|
||||||
nano::work_pool work (std::numeric_limits<unsigned>::max (), pow_rate_limiter);
|
nano::work_pool work (std::numeric_limits<unsigned>::max (), pow_rate_limiter);
|
||||||
nano::change_block block (0, 0, nano::keypair ().prv, 0, 0);
|
nano::change_block block (0, 0, nano::keypair ().prv, 0, 0);
|
||||||
std::cerr << "Starting generation profiling\n";
|
if (!result)
|
||||||
while (true)
|
{
|
||||||
|
std::cerr << boost::str (boost::format ("Starting generation profiling. Difficulty: %1$#x (%2%x from base difficulty %3$#x)\n") % difficulty % nano::to_string (nano::difficulty::to_multiplier (difficulty, network_constants.publish_full.base), 4) % network_constants.publish_full.base);
|
||||||
|
while (!result)
|
||||||
{
|
{
|
||||||
block.hashables.previous.qwords[0] += 1;
|
block.hashables.previous.qwords[0] += 1;
|
||||||
auto begin1 (std::chrono::high_resolution_clock::now ());
|
auto begin1 (std::chrono::high_resolution_clock::now ());
|
||||||
|
|
@ -328,6 +358,7 @@ int main (int argc, char * const * argv)
|
||||||
std::cerr << boost::str (boost::format ("%|1$ 12d|\n") % std::chrono::duration_cast<std::chrono::microseconds> (end1 - begin1).count ());
|
std::cerr << boost::str (boost::format ("%|1$ 12d|\n") % std::chrono::duration_cast<std::chrono::microseconds> (end1 - begin1).count ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (vm.count ("debug_profile_validate"))
|
else if (vm.count ("debug_profile_validate"))
|
||||||
{
|
{
|
||||||
uint64_t difficulty{ nano::network_constants ().publish_full.base };
|
uint64_t difficulty{ nano::network_constants ().publish_full.base };
|
||||||
|
|
@ -395,7 +426,23 @@ int main (int argc, char * const * argv)
|
||||||
result = -1;
|
result = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uint64_t difficulty (network_constants.publish_thresholds.base);
|
uint64_t difficulty (network_constants.publish_full.base);
|
||||||
|
auto multiplier_it = vm.find ("multiplier");
|
||||||
|
if (multiplier_it != vm.end ())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
auto multiplier (boost::lexical_cast<double> (multiplier_it->second.as<std::string> ()));
|
||||||
|
difficulty = nano::difficulty::from_multiplier (multiplier, difficulty);
|
||||||
|
}
|
||||||
|
catch (boost::bad_lexical_cast &)
|
||||||
|
{
|
||||||
|
std::cerr << "Invalid multiplier\n";
|
||||||
|
result = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
auto difficulty_it = vm.find ("difficulty");
|
auto difficulty_it = vm.find ("difficulty");
|
||||||
if (difficulty_it != vm.end ())
|
if (difficulty_it != vm.end ())
|
||||||
{
|
{
|
||||||
|
|
@ -404,10 +451,6 @@ int main (int argc, char * const * argv)
|
||||||
std::cerr << "Invalid difficulty\n";
|
std::cerr << "Invalid difficulty\n";
|
||||||
result = -1;
|
result = -1;
|
||||||
}
|
}
|
||||||
else if (difficulty < network_constants.publish_thresholds.base)
|
|
||||||
{
|
|
||||||
std::cerr << "Difficulty below publish threshold\n";
|
|
||||||
result = -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!result)
|
if (!result)
|
||||||
|
|
@ -426,7 +469,7 @@ int main (int argc, char * const * argv)
|
||||||
}
|
}
|
||||||
: std::function<boost::optional<uint64_t> (nano::work_version const, nano::root const &, uint64_t, std::atomic<int> &)> (nullptr));
|
: std::function<boost::optional<uint64_t> (nano::work_version const, nano::root const &, uint64_t, std::atomic<int> &)> (nullptr));
|
||||||
nano::change_block block (0, 0, nano::keypair ().prv, 0, 0);
|
nano::change_block block (0, 0, nano::keypair ().prv, 0, 0);
|
||||||
std::cerr << boost::str (boost::format ("Starting OpenCL generation profiling. Platform: %1%. Device: %2%. Threads: %3%. Difficulty: %4$#x\n") % platform % device % threads % difficulty);
|
std::cerr << boost::str (boost::format ("Starting OpenCL generation profiling. Platform: %1%. Device: %2%. Threads: %3%. Difficulty: %4$#x (%5%x from base difficulty %6$#x)\n") % platform % device % threads % difficulty % nano::to_string (nano::difficulty::to_multiplier (difficulty, network_constants.publish_full.base), 4) % network_constants.publish_full.base);
|
||||||
for (uint64_t i (0); true; ++i)
|
for (uint64_t i (0); true; ++i)
|
||||||
{
|
{
|
||||||
block.hashables.previous.qwords[0] += 1;
|
block.hashables.previous.qwords[0] += 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue