Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy: Check signature statuses in parallel #1384

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 27 additions & 25 deletions client/src/send_and_confirm_transactions_in_parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,33 +128,35 @@ fn create_transaction_confirmation_task(
})
.map(|x| *x.key())
.collect();
for signatures in
transactions_to_verify.chunks(MAX_GET_SIGNATURE_STATUSES_QUERY_ITEMS)
{
if let Ok(result) = rpc_client.get_signature_statuses(signatures).await {
let statuses = result.value;
for (signature, status) in signatures.iter().zip(statuses.into_iter()) {
if let Some((status, data)) = status
.filter(|status| {
status.satisfies_commitment(rpc_client.commitment())
})
.and_then(|status| {
unconfirmed_transaction_map
.remove(signature)
.map(|(_, data)| (status, data))
})
{
num_confirmed_transactions.fetch_add(1, Ordering::Relaxed);
match status.err {
Some(TransactionError::AlreadyProcessed) | None => {}
Some(error) => {
errors_map.insert(data.index, error);
let futures = transactions_to_verify
.chunks(MAX_GET_SIGNATURE_STATUSES_QUERY_ITEMS)
.map(|signatures| async {
if let Ok(result) = rpc_client.get_signature_statuses(signatures).await {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you a rein this code, I would prefer to exit early:

let Ok(result) = rpc_client.get_signature_statuses(signatures).await else {
    return;
};

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for me!

let statuses = result.value;
for (signature, status) in signatures.iter().zip(statuses.into_iter()) {
if let Some((status, data)) = status
.filter(|status| {
status.satisfies_commitment(rpc_client.commitment())
})
.and_then(|status| {
unconfirmed_transaction_map
.remove(signature)
.map(|(_, data)| (status, data))
})
{
num_confirmed_transactions.fetch_add(1, Ordering::Relaxed);
match status.err {
Some(TransactionError::AlreadyProcessed) | None => {}
Some(error) => {
errors_map.insert(data.index, error);
}
}
}
};
};
}
}
}
}
})
.collect::<Vec<_>>();
join_all(futures).await;

last_block_height = current_block_height;
}
Expand Down
Loading