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

reduce indent #2533

Merged
merged 1 commit into from
Aug 9, 2024
Merged
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
165 changes: 83 additions & 82 deletions rpc/src/transaction_status_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,93 +94,94 @@ impl TransactionStatusService {
token_balances.post_token_balances,
transaction_indexes,
) {
if let Ok(committed_tx) = commit_result {
let CommittedTransaction {
execution_details:
TransactionExecutionDetails {
status,
log_messages,
inner_instructions,
return_data,
executed_units,
..
},
fee_details,
rent_debits,
..
} = committed_tx;
let tx_account_locks = transaction.get_account_locks_unchecked();

let fee = fee_details.total_fee();
let inner_instructions = inner_instructions.map(|inner_instructions| {
map_inner_instructions(inner_instructions).collect()
});

let pre_token_balances = Some(pre_token_balances);
let post_token_balances = Some(post_token_balances);
let rewards = Some(
rent_debits
.into_unordered_rewards_iter()
.map(|(pubkey, reward_info)| Reward {
pubkey: pubkey.to_string(),
lamports: reward_info.lamports,
post_balance: reward_info.post_balance,
reward_type: Some(reward_info.reward_type),
commission: reward_info.commission,
})
.collect(),
let Ok(committed_tx) = commit_result else {
Copy link
Author

Choose a reason for hiding this comment

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

these few lines are the only real change. The rest of the diff is just changing the indent

continue;
};

let CommittedTransaction {
execution_details:
TransactionExecutionDetails {
status,
log_messages,
inner_instructions,
return_data,
executed_units,
..
},
fee_details,
rent_debits,
..
} = committed_tx;
let tx_account_locks = transaction.get_account_locks_unchecked();

let fee = fee_details.total_fee();
let inner_instructions = inner_instructions.map(|inner_instructions| {
map_inner_instructions(inner_instructions).collect()
});

let pre_token_balances = Some(pre_token_balances);
let post_token_balances = Some(post_token_balances);
let rewards = Some(
rent_debits
.into_unordered_rewards_iter()
.map(|(pubkey, reward_info)| Reward {
pubkey: pubkey.to_string(),
lamports: reward_info.lamports,
post_balance: reward_info.post_balance,
reward_type: Some(reward_info.reward_type),
commission: reward_info.commission,
})
.collect(),
);
let loaded_addresses = transaction.get_loaded_addresses();
let mut transaction_status_meta = TransactionStatusMeta {
status,
fee,
pre_balances,
post_balances,
inner_instructions,
log_messages,
pre_token_balances,
post_token_balances,
rewards,
loaded_addresses,
return_data,
compute_units_consumed: Some(executed_units),
};

if let Some(transaction_notifier) = transaction_notifier.as_ref() {
transaction_notifier.notify_transaction(
slot,
transaction_index,
transaction.signature(),
&transaction_status_meta,
&transaction,
);
let loaded_addresses = transaction.get_loaded_addresses();
let mut transaction_status_meta = TransactionStatusMeta {
status,
fee,
pre_balances,
post_balances,
inner_instructions,
log_messages,
pre_token_balances,
post_token_balances,
rewards,
loaded_addresses,
return_data,
compute_units_consumed: Some(executed_units),
};

if let Some(transaction_notifier) = transaction_notifier.as_ref() {
transaction_notifier.notify_transaction(
slot,
transaction_index,
transaction.signature(),
&transaction_status_meta,
&transaction,
);
}

if !(enable_extended_tx_metadata_storage || transaction_notifier.is_some())
{
transaction_status_meta.log_messages.take();
transaction_status_meta.inner_instructions.take();
transaction_status_meta.return_data.take();
}
}

if enable_rpc_transaction_history {
if let Some(memos) = extract_and_fmt_memos(transaction.message()) {
blockstore
.write_transaction_memos(transaction.signature(), slot, memos)
.expect("Expect database write to succeed: TransactionMemos");
}
if !(enable_extended_tx_metadata_storage || transaction_notifier.is_some()) {
transaction_status_meta.log_messages.take();
transaction_status_meta.inner_instructions.take();
transaction_status_meta.return_data.take();
}

if enable_rpc_transaction_history {
if let Some(memos) = extract_and_fmt_memos(transaction.message()) {
blockstore
.write_transaction_status(
slot,
*transaction.signature(),
tx_account_locks.writable,
tx_account_locks.readonly,
transaction_status_meta,
transaction_index,
)
.expect("Expect database write to succeed: TransactionStatus");
.write_transaction_memos(transaction.signature(), slot, memos)
.expect("Expect database write to succeed: TransactionMemos");
}

blockstore
.write_transaction_status(
slot,
*transaction.signature(),
tx_account_locks.writable,
tx_account_locks.readonly,
transaction_status_meta,
transaction_index,
)
.expect("Expect database write to succeed: TransactionStatus");
}
}
}
Expand Down