Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Move out of too-croweded bank.rs to proper file
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoqun committed May 13, 2023
1 parent f863c71 commit b44475b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
20 changes: 1 addition & 19 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ use {
status_cache::{SlotDelta, StatusCache},
storable_accounts::StorableAccounts,
system_instruction_processor::{get_system_account_kind, SystemAccountKind},
transaction_batch::TransactionBatch,
transaction_batch::{IntoCowForSanitizedTransaction, TransactionBatch},
transaction_error_metrics::TransactionErrorMetrics,
vote_account::{VoteAccount, VoteAccountsHashMap},
},
Expand Down Expand Up @@ -1198,24 +1198,6 @@ impl WorkingSlot for Bank {
}
}

pub trait IntoCowForSanitizedTransaction<'a>:
'a + Clone + std::borrow::Borrow<SanitizedTransaction>
{
fn into_cow(self) -> Cow<'a, [SanitizedTransaction]>;
}

impl<'a> IntoCowForSanitizedTransaction<'a> for SanitizedTransaction {
fn into_cow(self) -> Cow<'a, [SanitizedTransaction]> {
Cow::Owned(vec![self])
}
}

impl<'a> IntoCowForSanitizedTransaction<'a> for &'a SanitizedTransaction {
fn into_cow(self) -> Cow<'a, [SanitizedTransaction]> {
Cow::Borrowed(std::slice::from_ref(self))
}
}

impl Bank {
pub fn default_for_tests() -> Self {
Self::default_with_accounts(Accounts::default_for_tests())
Expand Down
18 changes: 18 additions & 0 deletions runtime/src/transaction_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@ impl<'a, 'b> Drop for TransactionBatch<'a, 'b> {
}
}

pub trait IntoCowForSanitizedTransaction<'a>:
'a + Clone + std::borrow::Borrow<SanitizedTransaction>
{
fn into_cow(self) -> Cow<'a, [SanitizedTransaction]>;
}

impl<'a> IntoCowForSanitizedTransaction<'a> for SanitizedTransaction {
fn into_cow(self) -> Cow<'a, [SanitizedTransaction]> {
Cow::Owned(vec![self])
}
}

impl<'a> IntoCowForSanitizedTransaction<'a> for &'a SanitizedTransaction {
fn into_cow(self) -> Cow<'a, [SanitizedTransaction]> {
Cow::Borrowed(std::slice::from_ref(self))
}
}

#[cfg(test)]
mod tests {
use {
Expand Down

0 comments on commit b44475b

Please sign in to comment.