Skip to content

Commit

Permalink
fix: make the first output optional in the wallet (#5352)
Browse files Browse the repository at this point in the history
Description
---
The PR prevents panic in getting the first output of the
`UtxoScannerTask`.

Motivation and Context
---
The `tari_console_wallet` app fails when a node is syncing:

```
 Base Node Status  - Chain Tip: #3498  Syncing...  Latency 630 ms
thread 'tokio-runtime-worker' panicked at 'index out of bounds: the len is 0 but the index is 0',
/home/denis/tari/base_layer/wallet/src/utxo_scanner_service/utxo_scanner_task.rs:484:37────────
 Network: esmeralda        Version: 0.50.0-pre.0    LeftArrow: Previous Tab  Tab/RightArrow: Next Tab
F10/Ctrl-note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Aborted (core dumped)
```

P.S. I wonder if the `None` value of the `first_output` variable breaks
something, and we must panic there.

How Has This Been Tested?
---
Manually, by starting the `tari_console_wallet` with the changes.
  • Loading branch information
therustmonk committed Apr 25, 2023
1 parent 2e2c8df commit bf16140
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ where
.into_iter()
.map(|utxo| TransactionOutput::try_from(utxo).map_err(UtxoScannerError::ConversionError))
.collect::<Result<Vec<_>, _>>()?;
let first_output = Some(outputs[0].clone());
let first_output = outputs.get(0).cloned();
total_scanned += outputs.len();

let start = Instant::now();
Expand Down

0 comments on commit bf16140

Please sign in to comment.