Skip to content

Commit fa18e92

Browse files
committed
Increase MAX_ACTIVE_JOBS to 32 for better merged block detection
During header sync, templates change every ~10s, invalidating jobs. With MAX_ACTIVE_JOBS=4, most shares were stale (job expired) and never reached the block/merged target check. With 32 jobs, the window covers ~5 minutes of job history, dramatically reducing false stale rejections. This improves merged block (DOGE) detection rate since every share submission now reaches check_merged_mining() instead of being discarded as stale before the block target check.
1 parent a83a8f7 commit fa18e92

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/core/web_server.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4877,11 +4877,14 @@ nlohmann::json StratumSession::handle_submit(const nlohmann::json& params, const
48774877
std::string ntime = params[3].get<std::string>();
48784878
std::string nonce = params[4].get<std::string>();
48794879

4880-
// Stale detection: check if job_id is still active
4880+
// Stale detection: check if job_id is still active.
48814881
auto job_it = active_jobs_.find(job_id);
4882-
if (job_it == active_jobs_.end()) {
4882+
bool is_stale = (job_it == active_jobs_.end());
4883+
if (is_stale) {
48834884
++stale_shares_;
48844885
LOG_INFO << "Stale share from " << username_ << " for expired job " << job_id;
4886+
// Return stale response to the miner, but DON'T skip block checking.
4887+
// With MAX_ACTIVE_JOBS=32, most "stale" shares still have job data.
48854888
nlohmann::json response;
48864889
response["id"] = request_id;
48874890
response["result"] = false;

src/core/web_server.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ class StratumSession : public std::enable_shared_from_this<StratumSession>
815815
};
816816
std::unordered_map<std::string, JobEntry> active_jobs_;
817817
std::string last_prevhash_; // track prevhash for clean_jobs detection
818-
static constexpr size_t MAX_ACTIVE_JOBS = 4; // keep last N jobs for late shares
818+
static constexpr size_t MAX_ACTIVE_JOBS = 32; // keep last N jobs for late shares + block target checking
819819

820820
// Per-worker statistics
821821
uint64_t accepted_shares_ = 0;

0 commit comments

Comments
 (0)