android: Start wallet no longer looks like a no-op while Cuprate launches
Tapping Start held the SQLCipher mutex for the whole in-process Node::launch and blocked the UniFFI tokio worker, so wallet_status stayed off with no error. Drop the store lock until creds are needed, spawn_blocking the sync start, and show that Start is in flight. The APK still runs Cuprate testnet only; this does not add mainnet or prune.
This commit is contained in:
parent
2df10124ef
commit
0acf89a0b4
7 changed files with 103 additions and 34 deletions
|
|
@ -609,7 +609,10 @@ impl Wire {
|
|||
///
|
||||
/// The spawn itself is synchronous inside the node: argv is built, the
|
||||
/// process is spawned, and a `.onion` source waits up to 20s for the SOCKS
|
||||
/// listener. Call it off the main thread, like `send_tip`.
|
||||
/// listener. An in-process Cuprate launch is the same shape and can take
|
||||
/// much longer. That work runs on `spawn_blocking` so it does not stall the
|
||||
/// UniFFI tokio worker (Android: a blocked worker is a Start tap that never
|
||||
/// returns).
|
||||
///
|
||||
/// Idempotent: a live child is reported, not respawned. Fails with
|
||||
/// `WireError.Failed` when no chain source is configured
|
||||
|
|
@ -621,7 +624,11 @@ impl Wire {
|
|||
/// and call [`Wire::wallet_status`] (or start again) for the later states.
|
||||
pub async fn start_wallet_child(&self) -> WResult<WalletChildStatus> {
|
||||
let node = self.node()?;
|
||||
node.start_wallet_child().map_err(WireError::new)?;
|
||||
let blocking = node.clone();
|
||||
tokio::task::spawn_blocking(move || blocking.start_wallet_child())
|
||||
.await
|
||||
.map_err(|e| WireError::new(format!("start wallet child join: {e}")))?
|
||||
.map_err(WireError::new)?;
|
||||
let source = node.wallet_child_config().source;
|
||||
Ok(child_status(node.wallet_child_refresh().await, &source))
|
||||
}
|
||||
|
|
@ -1337,11 +1344,7 @@ mod tests {
|
|||
Some("sending")
|
||||
);
|
||||
assert_eq!(
|
||||
delivery_of(
|
||||
"out",
|
||||
Some(OutboxStatus::Failed("no route".into()))
|
||||
)
|
||||
.as_deref(),
|
||||
delivery_of("out", Some(OutboxStatus::Failed("no route".into()))).as_deref(),
|
||||
Some("failed: no route")
|
||||
);
|
||||
}
|
||||
|
|
@ -1492,8 +1495,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn wallet_recent_transfers_on_stopped_handle_is_stopped_error() {
|
||||
let err =
|
||||
block_on(stopped_wire().wallet_recent_transfers(8)).expect_err("must fail");
|
||||
let err = block_on(stopped_wire().wallet_recent_transfers(8)).expect_err("must fail");
|
||||
assert!(matches!(err, WireError::Stopped { .. }), "got {err:?}");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue