Skip to content

Commit

Permalink
Don't skip unconfirmed messages (#847)
Browse files Browse the repository at this point in the history
* don't skip unconfirmed messages

* update comments and only skip confirmed messages
  • Loading branch information
Thoralf-M authored Dec 30, 2021
1 parent 492eb4f commit 6b204d1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/account/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ pub(crate) async fn sync_address(
let message_id = *found_output.message_id();

// if we already have the message stored
// and the confirmation state is known
// and the confirmation state is confirmed
// we skip the `get_message` call
if account_messages
.iter()
.any(|(id, confirmed)| id == &message_id && confirmed.is_some())
.any(|(id, confirmed)| id == &message_id && confirmed.unwrap_or(false))
{
return crate::Result::Ok((found_output, None));
}
Expand Down Expand Up @@ -452,11 +452,11 @@ async fn sync_messages(
let account = account_handle.read().await.clone();
let client_options = account.client_options().clone();

let messages_with_known_confirmation: Vec<MessageId> = account
let known_confirmed_messages: Vec<MessageId> = account
.with_messages(|messages| {
messages
.iter()
.filter(|m| m.confirmed.is_some())
.filter(|m| m.confirmed.unwrap_or(false))
.map(|m| m.key)
.collect()
})
Expand Down Expand Up @@ -492,7 +492,7 @@ async fn sync_messages(
continue;
}
let client = client.clone();
let messages_with_known_confirmation = messages_with_known_confirmation.clone();
let known_confirmed_messages = known_confirmed_messages.clone();
let mut outputs = address.outputs.clone();

tasks.push(async move {
Expand Down Expand Up @@ -573,9 +573,9 @@ async fn sync_messages(
outputs.insert(output.id()?, output);

// if we already have the message stored
// and the confirmation state is known
// and the confirmation state is confirmed
// we skip the `get_message` call
if messages_with_known_confirmation.contains(&output_message_id) {
if known_confirmed_messages.contains(&output_message_id) {
continue;
}

Expand Down

0 comments on commit 6b204d1

Please sign in to comment.