Add missing versioned tx support to BanksClient (#30958)
* replace Transaction params with impl Into<VersionedTransaction> * replace Vec<Transaction> with Vec<T> * fmt
This commit is contained in:
parent
4b7cfa23c1
commit
7c6572d5ec
|
@ -25,7 +25,7 @@ use {
|
||||||
commitment_config::CommitmentLevel,
|
commitment_config::CommitmentLevel,
|
||||||
message::Message,
|
message::Message,
|
||||||
signature::Signature,
|
signature::Signature,
|
||||||
transaction::{self, Transaction, VersionedTransaction},
|
transaction::{self, VersionedTransaction},
|
||||||
},
|
},
|
||||||
tarpc::{
|
tarpc::{
|
||||||
client::{self, NewClient, RequestDispatch},
|
client::{self, NewClient, RequestDispatch},
|
||||||
|
@ -231,7 +231,7 @@ impl BanksClient {
|
||||||
/// reached the given level of commitment.
|
/// reached the given level of commitment.
|
||||||
pub fn process_transaction_with_commitment(
|
pub fn process_transaction_with_commitment(
|
||||||
&mut self,
|
&mut self,
|
||||||
transaction: Transaction,
|
transaction: impl Into<VersionedTransaction>,
|
||||||
commitment: CommitmentLevel,
|
commitment: CommitmentLevel,
|
||||||
) -> impl Future<Output = Result<(), BanksClientError>> + '_ {
|
) -> impl Future<Output = Result<(), BanksClientError>> + '_ {
|
||||||
let ctx = context::current();
|
let ctx = context::current();
|
||||||
|
@ -258,7 +258,7 @@ impl BanksClient {
|
||||||
/// after the transaction has been rejected or reached the given level of commitment.
|
/// after the transaction has been rejected or reached the given level of commitment.
|
||||||
pub fn process_transaction_with_preflight_and_commitment(
|
pub fn process_transaction_with_preflight_and_commitment(
|
||||||
&mut self,
|
&mut self,
|
||||||
transaction: Transaction,
|
transaction: impl Into<VersionedTransaction>,
|
||||||
commitment: CommitmentLevel,
|
commitment: CommitmentLevel,
|
||||||
) -> impl Future<Output = Result<(), BanksClientError>> + '_ {
|
) -> impl Future<Output = Result<(), BanksClientError>> + '_ {
|
||||||
let ctx = context::current();
|
let ctx = context::current();
|
||||||
|
@ -294,7 +294,7 @@ impl BanksClient {
|
||||||
/// after the transaction has been finalized or rejected.
|
/// after the transaction has been finalized or rejected.
|
||||||
pub fn process_transaction_with_preflight(
|
pub fn process_transaction_with_preflight(
|
||||||
&mut self,
|
&mut self,
|
||||||
transaction: Transaction,
|
transaction: impl Into<VersionedTransaction>,
|
||||||
) -> impl Future<Output = Result<(), BanksClientError>> + '_ {
|
) -> impl Future<Output = Result<(), BanksClientError>> + '_ {
|
||||||
self.process_transaction_with_preflight_and_commitment(
|
self.process_transaction_with_preflight_and_commitment(
|
||||||
transaction,
|
transaction,
|
||||||
|
@ -305,14 +305,14 @@ impl BanksClient {
|
||||||
/// Send a transaction and return until the transaction has been finalized or rejected.
|
/// Send a transaction and return until the transaction has been finalized or rejected.
|
||||||
pub fn process_transaction(
|
pub fn process_transaction(
|
||||||
&mut self,
|
&mut self,
|
||||||
transaction: Transaction,
|
transaction: impl Into<VersionedTransaction>,
|
||||||
) -> impl Future<Output = Result<(), BanksClientError>> + '_ {
|
) -> impl Future<Output = Result<(), BanksClientError>> + '_ {
|
||||||
self.process_transaction_with_commitment(transaction, CommitmentLevel::default())
|
self.process_transaction_with_commitment(transaction, CommitmentLevel::default())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn process_transactions_with_commitment(
|
pub async fn process_transactions_with_commitment<T: Into<VersionedTransaction>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
transactions: Vec<Transaction>,
|
transactions: Vec<T>,
|
||||||
commitment: CommitmentLevel,
|
commitment: CommitmentLevel,
|
||||||
) -> Result<(), BanksClientError> {
|
) -> Result<(), BanksClientError> {
|
||||||
let mut clients: Vec<_> = transactions.iter().map(|_| self.clone()).collect();
|
let mut clients: Vec<_> = transactions.iter().map(|_| self.clone()).collect();
|
||||||
|
@ -327,9 +327,9 @@ impl BanksClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send transactions and return until the transaction has been finalized or rejected.
|
/// Send transactions and return until the transaction has been finalized or rejected.
|
||||||
pub fn process_transactions(
|
pub fn process_transactions<'a, T: Into<VersionedTransaction> + 'a>(
|
||||||
&mut self,
|
&'a mut self,
|
||||||
transactions: Vec<Transaction>,
|
transactions: Vec<T>,
|
||||||
) -> impl Future<Output = Result<(), BanksClientError>> + '_ {
|
) -> impl Future<Output = Result<(), BanksClientError>> + '_ {
|
||||||
self.process_transactions_with_commitment(transactions, CommitmentLevel::default())
|
self.process_transactions_with_commitment(transactions, CommitmentLevel::default())
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ impl BanksClient {
|
||||||
/// Simulate a transaction at the given commitment level
|
/// Simulate a transaction at the given commitment level
|
||||||
pub fn simulate_transaction_with_commitment(
|
pub fn simulate_transaction_with_commitment(
|
||||||
&mut self,
|
&mut self,
|
||||||
transaction: Transaction,
|
transaction: impl Into<VersionedTransaction>,
|
||||||
commitment: CommitmentLevel,
|
commitment: CommitmentLevel,
|
||||||
) -> impl Future<Output = Result<BanksTransactionResultWithSimulation, BanksClientError>> + '_
|
) -> impl Future<Output = Result<BanksTransactionResultWithSimulation, BanksClientError>> + '_
|
||||||
{
|
{
|
||||||
|
@ -351,7 +351,7 @@ impl BanksClient {
|
||||||
/// Simulate a transaction at the default commitment level
|
/// Simulate a transaction at the default commitment level
|
||||||
pub fn simulate_transaction(
|
pub fn simulate_transaction(
|
||||||
&mut self,
|
&mut self,
|
||||||
transaction: Transaction,
|
transaction: impl Into<VersionedTransaction>,
|
||||||
) -> impl Future<Output = Result<BanksTransactionResultWithSimulation, BanksClientError>> + '_
|
) -> impl Future<Output = Result<BanksTransactionResultWithSimulation, BanksClientError>> + '_
|
||||||
{
|
{
|
||||||
self.simulate_transaction_with_commitment(transaction, CommitmentLevel::default())
|
self.simulate_transaction_with_commitment(transaction, CommitmentLevel::default())
|
||||||
|
@ -534,7 +534,9 @@ mod tests {
|
||||||
bank::Bank, bank_forks::BankForks, commitment::BlockCommitmentCache,
|
bank::Bank, bank_forks::BankForks, commitment::BlockCommitmentCache,
|
||||||
genesis_utils::create_genesis_config,
|
genesis_utils::create_genesis_config,
|
||||||
},
|
},
|
||||||
solana_sdk::{message::Message, signature::Signer, system_instruction},
|
solana_sdk::{
|
||||||
|
message::Message, signature::Signer, system_instruction, transaction::Transaction,
|
||||||
|
},
|
||||||
std::sync::{Arc, RwLock},
|
std::sync::{Arc, RwLock},
|
||||||
tarpc::transport,
|
tarpc::transport,
|
||||||
tokio::{
|
tokio::{
|
||||||
|
|
Loading…
Reference in New Issue