Skip to content

Commit 6a2d78e

Browse files
committed
feat(cbf): add liveness check before returning requester
requester() now checks is_running() to give callers an immediate failure signal instead of waiting for SendError to propagate through the channel.
1 parent a9dced6 commit 6a2d78e

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/chain/cbf.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,16 @@ impl CbfChainSource {
481481
fn requester(&self) -> Result<Requester, Error> {
482482
let status = self.cbf_runtime_status.lock().unwrap();
483483
match &*status {
484-
CbfRuntimeStatus::Started { requester } => Ok(requester.clone()),
484+
CbfRuntimeStatus::Started { requester } if requester.is_running() => {
485+
Ok(requester.clone())
486+
},
487+
CbfRuntimeStatus::Started { .. } => {
488+
log_error!(
489+
self.logger,
490+
"CBF node is not running; sync will fail until restart completes."
491+
);
492+
Err(Error::ConnectionFailed)
493+
},
485494
CbfRuntimeStatus::Stopped => {
486495
debug_assert!(
487496
false,

0 commit comments

Comments
 (0)