checks non-finalized chain for unspent utxos before checking disk (#6513)

This commit is contained in:
Arya 2023-04-14 06:03:44 -04:00 committed by GitHub
parent 8edbf7990d
commit 6ed4b6632d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 19 deletions

View File

@ -152,25 +152,19 @@ fn transparent_spend_chain_order(
});
}
match (
non_finalized_chain_unspent_utxos.get(&spend),
finalized_state.utxo(&spend),
) {
(None, None) => {
// we don't keep spent UTXOs in the finalized state,
// so all we can say is that it's missing from both
// the finalized and non-finalized chains
// (it might have been spent in the finalized state,
// or it might never have existed in this chain)
Err(MissingTransparentOutput {
outpoint: spend,
location: "the non-finalized and finalized chain",
})
}
(Some(utxo), _) => Ok(utxo.clone()),
(_, Some(utxo)) => Ok(utxo),
}
non_finalized_chain_unspent_utxos
.get(&spend)
.cloned()
.or_else(|| finalized_state.utxo(&spend))
// we don't keep spent UTXOs in the finalized state,
// so all we can say is that it's missing from both
// the finalized and non-finalized chains
// (it might have been spent in the finalized state,
// or it might never have existed in this chain)
.ok_or(MissingTransparentOutput {
outpoint: spend,
location: "the non-finalized and finalized chain",
})
}
/// Check that `utxo` is spendable, based on the coinbase `spend_restriction`.