Skip to content

Commit

Permalink
Fix for issue where JDC stops receiving shares
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
xyephy committed Aug 26, 2024
1 parent 0f0ee1e commit 6c7c165
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions roles/jd-client/src/lib/downstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}",
Expand Down

0 comments on commit 6c7c165

Please sign in to comment.