From 6c7c16512076f6bf4539b4c2bcfead9e3970e7bd Mon Sep 17 00:00:00 2001 From: xyephy Date: Mon, 26 Aug 2024 16:35:19 +0300 Subject: [PATCH] Fix for issue where JDC stops receiving shares This PR addresses issue #920, where JDC stops receiving valid shares from the Translator when two new blocks are found within a few seconds. The problem occurs due to a race condition in the handling of SetCustomMiningJob messages, leading to the JDC not registering job IDs properly. --- roles/jd-client/src/lib/downstream.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/roles/jd-client/src/lib/downstream.rs b/roles/jd-client/src/lib/downstream.rs index 92e5a874a..bdd6be163 100644 --- a/roles/jd-client/src/lib/downstream.rs +++ b/roles/jd-client/src/lib/downstream.rs @@ -289,14 +289,22 @@ impl DownstreamMiningNode { // pool's job_id. The below return as soon as we have a pairable job id for the // template_id associated with this share. let last_template_id = self_mutex.safe_lock(|s| s.last_template_id).unwrap(); + // Await the job ID associated with the template, with a timeout let job_id_future = UpstreamMiningNode::get_job_id(&upstream_mutex, last_template_id); let job_id = match timeout(Duration::from_secs(10), job_id_future).await { Ok(job_id) => job_id, Err(_) => { + // Handle timeout or failure to get job ID + warn!( + "Failed to retrieve job_id for last_template_id: {}", + last_template_id + ); return; } }; + + // Assign the job ID to the share and send it upstream share.job_id = job_id; debug!( "Sending valid block solution upstream, with job_id {}",