diff --git a/crypto/util/Miner.cpp b/crypto/util/Miner.cpp index 88d7d7df..1a770821 100644 --- a/crypto/util/Miner.cpp +++ b/crypto/util/Miner.cpp @@ -117,15 +117,21 @@ void Miner::write_stats(std::string filename, const ton::Miner::Options &options if (passed < 1e-9) { passed = 1; } - double speed = static_cast(*options.hashes_computed) / passed; + double hashes_computed = options.hashes_computed ? static_cast(*options.hashes_computed) : 0; + double speed = hashes_computed / passed; std::stringstream ss, ss2; ss << std::fixed << std::setprecision(3) << speed / 1e+6; - double instant_passed = *options.instant_passed; + double instant_passed = 1; + if (options.instant_passed) { + instant_passed = *options.instant_passed; + } if (instant_passed < 1e-9) { instant_passed = 1; } - double instant_speed = static_cast(*options.instant_hashes_computed) / instant_passed; + + double instant_hashes_computed = options.instant_hashes_computed ? static_cast(*options.instant_hashes_computed) : 0; + double instant_speed = instant_hashes_computed / instant_passed; ss2 << std::fixed << std::setprecision(3) << instant_speed / 1e+6; td::JsonBuilder jb; @@ -135,10 +141,10 @@ void Miner::write_stats(std::string filename, const ton::Miner::Options &options jo("seed", hex_encode(td::Slice(options.seed.data(), options.seed.size()))); jo("complexity", hex_encode(td::Slice(options.complexity.data(), options.complexity.size()))); jo("passed", std::to_string(passed)); - jo("hashes_computed", std::to_string(*options.hashes_computed)); + jo("hashes_computed", std::to_string(hashes_computed)); jo("speed", ss.str()); jo("instant_passed", std::to_string(instant_passed)); - jo("instant_hashes_computed", std::to_string(*options.instant_hashes_computed)); + jo("instant_hashes_computed", std::to_string(instant_hashes_computed)); jo("instant_speed", ss2.str()); jo.leave(); auto s = jb.string_builder().as_cslice(); diff --git a/crypto/util/opencl/opencl.cpp b/crypto/util/opencl/opencl.cpp index 7ecf3f80..a401e599 100644 --- a/crypto/util/opencl/opencl.cpp +++ b/crypto/util/opencl/opencl.cpp @@ -36,7 +36,7 @@ void OpenCL::set_source(unsigned char *source, unsigned int length) { } } -void OpenCL::print_devices(bool count) { +void OpenCL::print_devices() { cl_int cl_err = CL_SUCCESS; // platform @@ -59,7 +59,7 @@ void OpenCL::print_devices(bool count) { CL_WRAPPER(clGetDeviceIDs(platforms_[p], CL_DEVICE_TYPE_ALL, device_count_, devices_, NULL)); for (uint i = 0; i < device_count_; i++) { CL_WRAPPER(clGetDeviceInfo(devices_[i], CL_DEVICE_NAME, sizeof(buf), buf, NULL)); - if (!count && GET_VERBOSITY_LEVEL() >= VERBOSITY_NAME(INFO)) { + if (GET_VERBOSITY_LEVEL() >= VERBOSITY_NAME(INFO)) { LOG(PLAIN) << "[ OpenCL: platform #" << p << " device #" << i << " " << buf << " ]"; } num_devices_++; diff --git a/crypto/util/opencl/opencl.h b/crypto/util/opencl/opencl.h index 4eed9d1d..ea535196 100644 --- a/crypto/util/opencl/opencl.h +++ b/crypto/util/opencl/opencl.h @@ -27,7 +27,7 @@ class OpenCL { OpenCL() = default; void load_source(const char *filename); void set_source(unsigned char *source, unsigned int length); - void print_devices(bool count = false); + void print_devices(); int get_num_devices(); void create_context(cl_uint platform_idx, cl_uint device_idx); void create_kernel(); diff --git a/crypto/util/pow-miner-howto.md b/crypto/util/pow-miner-howto.md index 90fac383..7f7e6974 100644 --- a/crypto/util/pow-miner-howto.md +++ b/crypto/util/pow-miner-howto.md @@ -115,7 +115,7 @@ It will save the data in the following format: {"timestamp":"1637264251.112240","giver":"Ef-FV4QTxLl-7Ct3E6MqOtMt-RGXMxi27g4I645lw6MTWg0f","seed":"B2A077AA6FCFE63FB0C8AAAEE1397A49","complexity":"000000000000E3C331D02EA44D1582443748E77D3997E69B37C5FD95D818D972","passed":"44.829463","hashes_computed":"13740539904","speed":"306.507","instant_passed":"4.981751","instant_hashes_computed":"1275068416","instant_speed":"255.948"} ``` -Log rotation is an automated process. To force rotate logs send the HANGUP to the tonlib-*-cli process. Log rotate threshold is 1Mb. +Log rotation is an automated process. To force rotate logs send the HANGUP to the tonlib-*-cli process. Log rotate threshold is 1MB. ## TONLIB CLI automation diff --git a/crypto/util/pow-miner.cpp b/crypto/util/pow-miner.cpp index 0362ed1f..ebe0942e 100644 --- a/crypto/util/pow-miner.cpp +++ b/crypto/util/pow-miner.cpp @@ -325,7 +325,7 @@ int main(int argc, char* const argv[]) { #if defined MINEROPENCL auto opencl = opencl::OpenCL(); - opencl.print_devices(true); + opencl.print_devices(); if (opencl.get_num_devices() == 0) { std::cerr << "No OpenCL-capable devices is detected!" << std::endl; exit(1); diff --git a/tonlib/tonlib/tonlib-cli.cpp b/tonlib/tonlib/tonlib-cli.cpp index 493ce0a8..5256283b 100644 --- a/tonlib/tonlib/tonlib-cli.cpp +++ b/tonlib/tonlib/tonlib-cli.cpp @@ -724,7 +724,7 @@ class TonlibCli : public td::actor::Actor { next_options_query_at_ = {}; // show status - if (miner_options_copy_.verbosity >= 2) { + if (miner_options_copy_.verbosity >= 2 && options_.giver_address.address) { ton::Miner::print_stats("mining in progress", miner_options_copy_.start_at, hashes_computed_, instant_passed_, instant_hashes_computed_); ton::Miner::write_stats(options_.statfile, miner_options_copy_, @@ -2698,7 +2698,7 @@ int main(int argc, char* argv[]) { }); p.add_option('l', "logname", "log to file", [&](td::Slice fname) { options.logfile = fname.str(); - // 1 Mb log threshold + // 1MB log threshold logger_ = td::TsFileLog::create(fname.str(), 1 * (1 << 20), true, true).move_as_ok(); td::set_signal_handler(td::SignalType::HangUp, force_rotate_logs).ensure(); td::log_interface = logger_.get();