Replace get_clock by get_sysvar in BanksClient
This commit is contained in:
parent
b30b32300d
commit
5d21f63e8a
|
@ -10,8 +10,8 @@ use futures::{future::join_all, Future, FutureExt};
|
||||||
pub use solana_banks_interface::{BanksClient as TarpcClient, TransactionStatus};
|
pub use solana_banks_interface::{BanksClient as TarpcClient, TransactionStatus};
|
||||||
use solana_banks_interface::{BanksRequest, BanksResponse};
|
use solana_banks_interface::{BanksRequest, BanksResponse};
|
||||||
use solana_program::{
|
use solana_program::{
|
||||||
clock::Clock, clock::Slot, fee_calculator::FeeCalculator, hash::Hash, program_pack::Pack,
|
clock::Slot, fee_calculator::FeeCalculator, hash::Hash, program_pack::Pack, pubkey::Pubkey,
|
||||||
pubkey::Pubkey, rent::Rent, sysvar,
|
rent::Rent, sysvar::Sysvar,
|
||||||
};
|
};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::{from_account, Account},
|
account::{from_account, Account},
|
||||||
|
@ -114,17 +114,6 @@ impl BanksClient {
|
||||||
self.send_transaction_with_context(context::current(), transaction)
|
self.send_transaction_with_context(context::current(), transaction)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the cluster clock
|
|
||||||
pub fn get_clock(&mut self) -> impl Future<Output = io::Result<Clock>> + '_ {
|
|
||||||
self.get_account(sysvar::clock::id()).map(|result| {
|
|
||||||
let clock_sysvar = result?
|
|
||||||
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Clock sysvar not present"))?;
|
|
||||||
from_account::<Clock, _>(&clock_sysvar).ok_or_else(|| {
|
|
||||||
io::Error::new(io::ErrorKind::Other, "Failed to deserialize Clock sysvar")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return the fee parameters associated with a recent, rooted blockhash. The cluster
|
/// Return the fee parameters associated with a recent, rooted blockhash. The cluster
|
||||||
/// will use the transaction's blockhash to look up these same fee parameters and
|
/// will use the transaction's blockhash to look up these same fee parameters and
|
||||||
/// use them to calculate the transaction fee.
|
/// use them to calculate the transaction fee.
|
||||||
|
@ -134,15 +123,19 @@ impl BanksClient {
|
||||||
self.get_fees_with_commitment_and_context(context::current(), CommitmentLevel::default())
|
self.get_fees_with_commitment_and_context(context::current(), CommitmentLevel::default())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the cluster Sysvar
|
||||||
|
pub fn get_sysvar<T: Sysvar>(&mut self) -> impl Future<Output = io::Result<T>> + '_ {
|
||||||
|
self.get_account(T::id()).map(|result| {
|
||||||
|
let sysvar = result?
|
||||||
|
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Sysvar not present"))?;
|
||||||
|
from_account::<T, _>(&sysvar)
|
||||||
|
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Failed to deserialize sysvar"))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/// Return the cluster rent
|
/// Return the cluster rent
|
||||||
pub fn get_rent(&mut self) -> impl Future<Output = io::Result<Rent>> + '_ {
|
pub fn get_rent(&mut self) -> impl Future<Output = io::Result<Rent>> + '_ {
|
||||||
self.get_account(sysvar::rent::id()).map(|result| {
|
self.get_sysvar::<Rent>()
|
||||||
let rent_sysvar = result?
|
|
||||||
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Rent sysvar not present"))?;
|
|
||||||
from_account::<Rent, _>(&rent_sysvar).ok_or_else(|| {
|
|
||||||
io::Error::new(io::ErrorKind::Other, "Failed to deserialize Rent sysvar")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return a recent, rooted blockhash from the server. The cluster will only accept
|
/// Return a recent, rooted blockhash from the server. The cluster will only accept
|
||||||
|
|
Loading…
Reference in New Issue