Skip to content

Commit

Permalink
fix: remove wallet panic (#5338)
Browse files Browse the repository at this point in the history
Description
---
Removes a potential panic in the wallet that can occur

How Has This Been Tested?
---
manual and unit tests
  • Loading branch information
SWvheerden authored May 3, 2023
1 parent 1e2f103 commit 536d16d
Showing 1 changed file with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,6 @@ where
let mut utxo_next_await_profiling = Vec::new();
let mut scan_for_outputs_profiling = Vec::new();
let mut prev_scanned_block: Option<ScannedBlock> = None;
let mut prev_output = None;
while let Some(response) = {
let start = Instant::now();
let utxo_stream_next = utxo_stream.next().await;
Expand All @@ -481,7 +480,6 @@ where
.into_iter()
.map(|utxo| TransactionOutput::try_from(utxo).map_err(UtxoScannerError::ConversionError))
.collect::<Result<Vec<_>, _>>()?;
let first_output = outputs.get(0).cloned();
total_scanned += outputs.len();

let start = Instant::now();
Expand All @@ -493,7 +491,7 @@ where
.await?;
let block_hash = current_header_hash.try_into()?;
if let Some(scanned_block) = prev_scanned_block {
if block_hash == scanned_block.header_hash && first_output == prev_output {
if block_hash == scanned_block.header_hash {
count += scanned_block.num_outputs.unwrap_or(0);
amount += scanned_block.amount.unwrap_or_else(|| 0.into())
} else {
Expand All @@ -518,7 +516,6 @@ where
total_amount += amount;
}
}
prev_output = first_output;
prev_scanned_block = Some(ScannedBlock {
header_hash: block_hash,
height: current_height,
Expand Down

0 comments on commit 536d16d

Please sign in to comment.