diff --git a/include/mmx/Harvester.h b/include/mmx/Harvester.h index 21384bba1..2f8b95c31 100644 --- a/include/mmx/Harvester.h +++ b/include/mmx/Harvester.h @@ -67,6 +67,7 @@ class Harvester : public HarvesterBase { const uint32_t score, const int64_t time_begin_ms) const; private: + bool is_ready = false; hash_t harvester_id; uint64_t total_bytes = 0; uint64_t total_bytes_effective = 0; diff --git a/src/Farmer.cpp b/src/Farmer.cpp index dcebffbfe..9dec723e5 100644 --- a/src/Farmer.cpp +++ b/src/Farmer.cpp @@ -78,14 +78,16 @@ uint64_t Farmer::get_partial_diff(const addr_t& plot_nft) const return stats.partial_diff; } } - return 1; + return 0; } std::map Farmer::get_partial_diffs(const std::vector& plot_nfts) const { std::map out; for(const auto& addr : plot_nfts) { - out[addr] = get_partial_diff(addr); + if(auto diff = get_partial_diff(addr)) { + out[addr] = diff; + } } return out; } diff --git a/src/Harvester.cpp b/src/Harvester.cpp index b9c79a474..7662ddb70 100644 --- a/src/Harvester.cpp +++ b/src/Harvester.cpp @@ -130,7 +130,7 @@ void Harvester::check_queue() void Harvester::handle(std::shared_ptr value) { - if(value->max_delay < 2) { + if(!is_ready || value->max_delay < 2) { return; } if(!already_checked.insert(value->challenge).second) { @@ -643,8 +643,8 @@ void Harvester::reload() } } for(const auto& entry : plot_map) { - if(auto contract = entry.second->get_contract()) { - plot_contract_set[*contract]++; + if(const auto& addr = entry.second->get_contract()) { + plot_contract_set[*addr]++; } } @@ -653,8 +653,14 @@ void Harvester::reload() // check challenges again for new plots if(plots.size()) { + is_ready = false; already_checked.clear(); } + if(!is_ready) { + set_timeout_millis(3000, [this]() { + is_ready = true; + }); + } log(INFO) << "[" << my_name << "] Loaded " << plot_map.size() << " plots, " << total_bytes / pow(1000, 4) << " TB, " << total_bytes_effective / pow(1000, 4) << " TBe, " << virtual_map.size() << " virtual plots, " << total_balance / pow(10, params->decimals) << " MMX total, took " @@ -742,6 +748,7 @@ void Harvester::update_nfts() } if(--(*job) == 0) { update(); + set_timeout_millis(2000, std::bind(&Harvester::update, this)); } }, [this, address](const std::exception& ex) {