Skip to content

Commit

Permalink
reduce tss indent (anza-xyz#2533)
Browse files Browse the repository at this point in the history
  • Loading branch information
bw-solana authored and ray-kast committed Nov 27, 2024
1 parent cc2ccad commit a2a8d0c
Showing 1 changed file with 83 additions and 82 deletions.
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 {
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

0 comments on commit a2a8d0c

Please sign in to comment.