Skip to content

Commit 444cf55

Browse files
authored
Merge pull request #422 from plebhash/2026-04-08-fix-jdc-pool-drop-on-no-bitcoin-conn
JDC exits immediately if `node.sock` is not available (no retry)
2 parents 697157f + 4c2e130 commit 444cf55

File tree

1 file changed

+23
-2
lines changed
  • miner-apps/jd-client/src/lib

1 file changed

+23
-2
lines changed

miner-apps/jd-client/src/lib/mod.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,13 @@ impl JobDeclaratorClient {
643643
upstream_entry.jds_port,
644644
);
645645

646-
tokio::time::sleep(Duration::from_secs(1)).await;
646+
tokio::select! {
647+
_ = cancellation_token.cancelled() => {
648+
info!("Shutdown requested while waiting to initialize upstream, aborting retries");
649+
return Err(JDCErrorKind::CouldNotInitiateSystem);
650+
}
651+
_ = tokio::time::sleep(Duration::from_secs(1)) => {}
652+
}
647653

648654
if upstream_entry.tried_or_flagged {
649655
info!(
@@ -653,6 +659,13 @@ impl JobDeclaratorClient {
653659
}
654660

655661
for attempt in 1..=MAX_RETRIES {
662+
if cancellation_token.is_cancelled() {
663+
info!(
664+
"Shutdown requested before upstream connection attempt, aborting retries"
665+
);
666+
return Err(JDCErrorKind::CouldNotInitiateSystem);
667+
}
668+
656669
info!("Connection attempt {}/{}...", attempt, MAX_RETRIES);
657670

658671
match try_initialize_single(
@@ -675,7 +688,15 @@ impl JobDeclaratorClient {
675688
}
676689
Err(e) => {
677690
tracing::error!("Upstream and JDS connection terminated");
678-
tokio::time::sleep(Duration::from_secs(1)).await;
691+
692+
tokio::select! {
693+
_ = cancellation_token.cancelled() => {
694+
info!("Shutdown requested after upstream initialization failure, aborting retries");
695+
return Err(JDCErrorKind::CouldNotInitiateSystem);
696+
}
697+
_ = tokio::time::sleep(Duration::from_secs(1)) => {}
698+
}
699+
679700
warn!(
680701
"Attempt {}/{} failed for pool={}:{}, jds={}:{}: {:?}",
681702
attempt,

0 commit comments

Comments
 (0)