From 1717db430b7e2a23d627f876bd3b4b7c321c246c Mon Sep 17 00:00:00 2001 From: aglkm <39521015+aglkm@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:54:44 +0300 Subject: [PATCH] another panick fix on startup if node is not fully synced --- src/requests.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/requests.rs b/src/requests.rs index b60c6e6..ac66ec5 100644 --- a/src/requests.rs +++ b/src/requests.rs @@ -783,12 +783,14 @@ pub async fn get_unspent_outputs(dashboard: Arc>) -> Result<(), let resp = call("get_unspent_outputs", params, "1", "foreign").await?; if resp != Value::Null { - if let Some(v) = resp["result"]["Ok"]["outputs"].as_array().unwrap().last() { - current_mmr_index = v["mmr_index"].to_string().parse::().unwrap(); - utxo_count = utxo_count + resp["result"]["Ok"]["outputs"].as_array().unwrap().len(); - } else { - // Break the loop if we got no outputs from the node request - break; + if resp["result"]["Ok"]["outputs"] != Value::Null { + if let Some(v) = resp["result"]["Ok"]["outputs"].as_array().unwrap().last() { + current_mmr_index = v["mmr_index"].to_string().parse::().unwrap(); + utxo_count = utxo_count + resp["result"]["Ok"]["outputs"].as_array().unwrap().len(); + } else { + // Break the loop if we got no outputs from the node request + break; + } } } }