Skip to content

Commit

Permalink
Make get_transaction() yieldy
Browse files Browse the repository at this point in the history
When this method reaches out to blockstore, yield the thread
  • Loading branch information
steveluscher committed Dec 11, 2024
1 parent fce3717 commit f45c5f1
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1710,13 +1710,22 @@ impl JsonRpcRequestProcessor {

if self.config.enable_rpc_transaction_history {
let confirmed_bank = self.bank(Some(CommitmentConfig::confirmed()));
let confirmed_transaction = if commitment.is_confirmed() {
let highest_confirmed_slot = confirmed_bank.slot();
self.blockstore
.get_complete_transaction(signature, highest_confirmed_slot)
} else {
self.blockstore.get_rooted_transaction(signature)
};
let confirmed_transaction = self
.runtime
.spawn_blocking({
let blockstore = Arc::clone(&self.blockstore);
let confirmed_bank = Arc::clone(&confirmed_bank);
move || {
if commitment.is_confirmed() {
let highest_confirmed_slot = confirmed_bank.slot();
blockstore.get_complete_transaction(signature, highest_confirmed_slot)
} else {
blockstore.get_rooted_transaction(signature)
}
}
})
.await
.expect("Failed to spawn blocking task");

let encode_transaction =
|confirmed_tx_with_meta: ConfirmedTransactionWithStatusMeta| -> Result<EncodedConfirmedTransactionWithStatusMeta> {
Expand Down

0 comments on commit f45c5f1

Please sign in to comment.