deprecate FeeCalculator in BanksClients (#21056)
This commit is contained in:
parent
0b8fcf0808
commit
3140d7741c
|
@ -17,6 +17,7 @@ use {
|
||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
account::{from_account, Account},
|
account::{from_account, Account},
|
||||||
commitment_config::CommitmentLevel,
|
commitment_config::CommitmentLevel,
|
||||||
|
message::Message,
|
||||||
signature::Signature,
|
signature::Signature,
|
||||||
transaction::{self, Transaction},
|
transaction::{self, Transaction},
|
||||||
transport,
|
transport,
|
||||||
|
@ -65,6 +66,7 @@ impl BanksClient {
|
||||||
ctx: Context,
|
ctx: Context,
|
||||||
commitment: CommitmentLevel,
|
commitment: CommitmentLevel,
|
||||||
) -> impl Future<Output = io::Result<(FeeCalculator, Hash, u64)>> + '_ {
|
) -> impl Future<Output = io::Result<(FeeCalculator, Hash, u64)>> + '_ {
|
||||||
|
#[allow(deprecated)]
|
||||||
self.inner
|
self.inner
|
||||||
.get_fees_with_commitment_and_context(ctx, commitment)
|
.get_fees_with_commitment_and_context(ctx, commitment)
|
||||||
}
|
}
|
||||||
|
@ -312,6 +314,16 @@ impl BanksClient {
|
||||||
// Convert Vec<Result<_, _>> to Result<Vec<_>>
|
// Convert Vec<Result<_, _>> to Result<Vec<_>>
|
||||||
statuses.into_iter().collect()
|
statuses.into_iter().collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_fee_for_message_with_commitment_and_context(
|
||||||
|
&mut self,
|
||||||
|
ctx: Context,
|
||||||
|
commitment: CommitmentLevel,
|
||||||
|
message: Message,
|
||||||
|
) -> impl Future<Output = io::Result<Option<u64>>> + '_ {
|
||||||
|
self.inner
|
||||||
|
.get_fee_for_message_with_commitment_and_context(ctx, commitment, message)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn start_client<C>(transport: C) -> io::Result<BanksClient>
|
pub async fn start_client<C>(transport: C) -> io::Result<BanksClient>
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![allow(deprecated)]
|
||||||
|
|
||||||
use {
|
use {
|
||||||
serde::{Deserialize, Serialize},
|
serde::{Deserialize, Serialize},
|
||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
|
@ -6,6 +8,7 @@ use {
|
||||||
commitment_config::CommitmentLevel,
|
commitment_config::CommitmentLevel,
|
||||||
fee_calculator::FeeCalculator,
|
fee_calculator::FeeCalculator,
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
|
message::Message,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
signature::Signature,
|
signature::Signature,
|
||||||
transaction::{self, Transaction, TransactionError},
|
transaction::{self, Transaction, TransactionError},
|
||||||
|
@ -30,6 +33,10 @@ pub struct TransactionStatus {
|
||||||
#[tarpc::service]
|
#[tarpc::service]
|
||||||
pub trait Banks {
|
pub trait Banks {
|
||||||
async fn send_transaction_with_context(transaction: Transaction);
|
async fn send_transaction_with_context(transaction: Transaction);
|
||||||
|
#[deprecated(
|
||||||
|
since = "1.9.0",
|
||||||
|
note = "Please use `get_fee_for_message_with_commitment_and_context` instead"
|
||||||
|
)]
|
||||||
async fn get_fees_with_commitment_and_context(
|
async fn get_fees_with_commitment_and_context(
|
||||||
commitment: CommitmentLevel,
|
commitment: CommitmentLevel,
|
||||||
) -> (FeeCalculator, Hash, Slot);
|
) -> (FeeCalculator, Hash, Slot);
|
||||||
|
@ -45,6 +52,10 @@ pub trait Banks {
|
||||||
address: Pubkey,
|
address: Pubkey,
|
||||||
commitment: CommitmentLevel,
|
commitment: CommitmentLevel,
|
||||||
) -> Option<Account>;
|
) -> Option<Account>;
|
||||||
|
async fn get_fee_for_message_with_commitment_and_context(
|
||||||
|
commitment: CommitmentLevel,
|
||||||
|
message: Message,
|
||||||
|
) -> Option<u64>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -13,6 +13,7 @@ use {
|
||||||
commitment_config::CommitmentLevel,
|
commitment_config::CommitmentLevel,
|
||||||
fee_calculator::FeeCalculator,
|
fee_calculator::FeeCalculator,
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
|
message::{Message, SanitizedMessage},
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
signature::Signature,
|
signature::Signature,
|
||||||
transaction::{self, Transaction},
|
transaction::{self, Transaction},
|
||||||
|
@ -22,6 +23,7 @@ use {
|
||||||
tpu_info::NullTpuInfo,
|
tpu_info::NullTpuInfo,
|
||||||
},
|
},
|
||||||
std::{
|
std::{
|
||||||
|
convert::TryFrom,
|
||||||
io,
|
io,
|
||||||
net::{Ipv4Addr, SocketAddr},
|
net::{Ipv4Addr, SocketAddr},
|
||||||
sync::{
|
sync::{
|
||||||
|
@ -278,6 +280,17 @@ impl Banks for BanksServer {
|
||||||
let bank = self.bank(commitment);
|
let bank = self.bank(commitment);
|
||||||
bank.get_account(&address).map(Account::from)
|
bank.get_account(&address).map(Account::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn get_fee_for_message_with_commitment_and_context(
|
||||||
|
self,
|
||||||
|
_: Context,
|
||||||
|
commitment: CommitmentLevel,
|
||||||
|
message: Message,
|
||||||
|
) -> Option<u64> {
|
||||||
|
let bank = self.bank(commitment);
|
||||||
|
let sanitized_message = SanitizedMessage::try_from(message).ok()?;
|
||||||
|
Some(bank.get_fee_for_message(&sanitized_message))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn start_local_server(
|
pub async fn start_local_server(
|
||||||
|
|
Loading…
Reference in New Issue