perf(message): check if output already exist on account addresses
@@ -389,6 +389,18 @@ impl TransactionRegularEssence {
let metadata: Option<AddressOutput> = None;
#[cfg(not(test))]
let metadata = {
+ let mut output = None;
+ for address in metadata.account_addresses {
+ if let Some(found_output) = address.outputs().iter().find(|o| {
+ &o.transaction_id == i.output_id().transaction_id() && o.index == i.output_id().index()
+ }) {
+ output = Some(found_output.clone());
+ break;
+ }
+ }
+ if let Some(output) = output {
+ Some(output)
+ } else {
let client = crate::client::get_client(metadata.client_options).await;
let client = client.read().await;
if let Ok(output) = client.get_output(&i).await {
@@ -397,6 +409,7 @@ impl TransactionRegularEssence {
} else {
None
}
+ }
};
TransactionInput::UTXO(TransactionUTXOInput { input: i, metadata })
}
