wallet: show the chain daemon's sync height and target on the child status
The user watching an in-process Cuprate node on Android saw only a phase word (connecting, with 'wallet connect: Connection refused (os error 111)') and asked to see height vs tip. - WalletChildStatus gains height / target_height, and line() appends 'sync h/t' when a probe read either number. No percentage is invented when the daemon reports no target (h/0 is honest), and an off/exited child reports 0/0. - Node::wallet_child_refresh fills them: one wallet-RPC get_info now answers both the readiness gate and the numbers (Wallet::chain_info, with chain_ready built on the same parse), and when the wallet RPC is down while the chain source is local/in-process, the loopback daemon is asked directly (ChildConfig::daemon_probe_addr). A refused daemon stays 0/0 — unknown, not caught up. Only refresh dials; the draw path reads two atomics. - UniFFI WalletChildStatus carries the same two u64 fields so Android can show them; SDK test covers the round trip. Tests: cargo test --locked --target x86_64-unknown-linux-gnu (all green), clippy -D warnings clean; crates/onionwire-sdk cargo test --locked + clippy clean (separate workspace).
This commit is contained in:
parent
bc74b4f4af
commit
0a91744924
5 changed files with 468 additions and 17 deletions
|
|
@ -872,6 +872,8 @@ fn child_status(
|
|||
} else {
|
||||
String::new()
|
||||
},
|
||||
height: status.height,
|
||||
target_height: status.target_height,
|
||||
last_error: status.last_error,
|
||||
}
|
||||
}
|
||||
|
|
@ -1077,6 +1079,14 @@ pub struct WalletChildStatus {
|
|||
/// node's side (the daemon's loopback RPC has not answered yet); it is
|
||||
/// never persisted, polled from a file, or inferred from a timeout.
|
||||
pub node_state: String,
|
||||
/// Blocks the chain daemon had at the last probe, as the wallet RPC (or the
|
||||
/// daemon itself, over loopback) reported them. `0` means unknown: never
|
||||
/// probed, the child is off/exited, or the probe failed — it is not the
|
||||
/// same as caught up, and it is never a wallet-scan height.
|
||||
pub height: u64,
|
||||
/// Blocks the daemon was syncing towards. `0` means the daemon reported
|
||||
/// none (also not the same as caught up).
|
||||
pub target_height: u64,
|
||||
/// The last failure, display-ready. Never carries the generated login.
|
||||
pub last_error: Option<String>,
|
||||
}
|
||||
|
|
@ -1889,6 +1899,8 @@ mod tests {
|
|||
running: true,
|
||||
configured: true,
|
||||
chain_source: "in-process node".to_string(),
|
||||
height: 0,
|
||||
target_height: 0,
|
||||
last_error: None,
|
||||
}
|
||||
}
|
||||
|
|
@ -1960,4 +1972,29 @@ mod tests {
|
|||
let status = child_status(core_status(WalletChildState::Off), &ChainSource::None);
|
||||
assert_eq!(status.node_available, onionwire::cuprate::available());
|
||||
}
|
||||
|
||||
/// The chain's own progress reaches Kotlin: a snapshot that carries the
|
||||
/// daemon's height and target copies both numbers onto the record, so an
|
||||
/// Android status line can show `1160/3090939` without a second probe.
|
||||
#[test]
|
||||
fn the_daemons_height_and_target_reach_the_sdk_record() {
|
||||
let mut core = core_status(WalletChildState::Connecting);
|
||||
core.height = 1160;
|
||||
core.target_height = 3_090_939;
|
||||
let status = child_status(core, &ChainSource::None);
|
||||
assert_eq!(status.height, 1160);
|
||||
assert_eq!(status.target_height, 3_090_939);
|
||||
// The core's own word still passes straight through: the numbers are an
|
||||
// addition, not a second state machine.
|
||||
assert_eq!(status.state, "connecting");
|
||||
}
|
||||
|
||||
/// A snapshot with nothing to report keeps `0/0`: unknown is not caught up,
|
||||
/// and no percentage is invented on the way out.
|
||||
#[test]
|
||||
fn an_unprobed_child_reports_an_unknown_chain_progress() {
|
||||
let status = child_status(core_status(WalletChildState::Off), &ChainSource::None);
|
||||
assert_eq!(status.height, 0);
|
||||
assert_eq!(status.target_height, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue