wallet: a connect refusal while coming up is not a status error

This commit is contained in:
agent 2026-09-23 20:33:49 -04:00
commit 4136f36dd4
No known key found for this signature in database
2 changed files with 85 additions and 10 deletions

View file

@ -19,17 +19,23 @@ impl std::fmt::Display for Error {
impl std::error::Error for Error {}
/// Is this failure "the wallet RPC is not answering yet"? That is the one class
/// a retry can fix — a freshly spawned `monero-wallet-rpc` binds its port a
/// moment after `spawn` returns. Everything else (a refused passphrase, a
/// protocol error) is the RPC's own answer and retrying it would only repeat it.
///
/// Deliberately *not* the timeout: a hung child is not a start in progress.
///
/// The free function is the rule itself: a status row keeps an already
/// formatted `String`, and it must apply exactly the same test to it.
pub fn error_is_unreachable(msg: &str) -> bool {
msg.starts_with("wallet connect:") || msg.starts_with("wallet write:")
}
impl Error {
/// Is this failure "the wallet RPC is not answering yet"? That is the one
/// class a retry can fix — a freshly spawned `monero-wallet-rpc` binds its
/// port a moment after `spawn` returns. Everything else (a refused
/// passphrase, a protocol error) is the RPC's own answer and retrying it
/// would only repeat it.
///
/// Deliberately *not* the timeout: a hung child is not a start in progress.
/// [`error_is_unreachable`], on this error's own message.
pub fn is_unreachable(&self) -> bool {
let msg = self.0.as_str();
msg.starts_with("wallet connect:") || msg.starts_with("wallet write:")
error_is_unreachable(self.0.as_str())
}
}