Add get_rent()
This commit is contained in:
parent
920cd5285a
commit
9a1c1fbab8
|
@ -10,9 +10,17 @@ use futures::future::join_all;
|
||||||
pub use solana_banks_interface::{BanksClient, TransactionStatus};
|
pub use solana_banks_interface::{BanksClient, TransactionStatus};
|
||||||
use solana_banks_interface::{BanksRequest, BanksResponse};
|
use solana_banks_interface::{BanksRequest, BanksResponse};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::Account, clock::Slot, commitment_config::CommitmentLevel,
|
account::{from_account, Account},
|
||||||
fee_calculator::FeeCalculator, hash::Hash, pubkey::Pubkey, signature::Signature,
|
clock::Slot,
|
||||||
transaction::Transaction, transport,
|
commitment_config::CommitmentLevel,
|
||||||
|
fee_calculator::FeeCalculator,
|
||||||
|
hash::Hash,
|
||||||
|
pubkey::Pubkey,
|
||||||
|
rent::Rent,
|
||||||
|
signature::Signature,
|
||||||
|
sysvar,
|
||||||
|
transaction::Transaction,
|
||||||
|
transport,
|
||||||
};
|
};
|
||||||
use std::io::{self, Error, ErrorKind};
|
use std::io::{self, Error, ErrorKind};
|
||||||
use tarpc::{
|
use tarpc::{
|
||||||
|
@ -40,6 +48,9 @@ pub trait BanksClientExt {
|
||||||
/// use them to calculate the transaction fee.
|
/// use them to calculate the transaction fee.
|
||||||
async fn get_fees(&mut self) -> io::Result<(FeeCalculator, Hash, Slot)>;
|
async fn get_fees(&mut self) -> io::Result<(FeeCalculator, Hash, Slot)>;
|
||||||
|
|
||||||
|
/// Return the cluster rent
|
||||||
|
async fn get_rent(&mut self) -> io::Result<Rent>;
|
||||||
|
|
||||||
/// Send a transaction and return after the transaction has been rejected or
|
/// Send a transaction and return after the transaction has been rejected or
|
||||||
/// reached the given level of commitment.
|
/// reached the given level of commitment.
|
||||||
async fn process_transaction_with_commitment(
|
async fn process_transaction_with_commitment(
|
||||||
|
@ -108,6 +119,17 @@ impl BanksClientExt for BanksClient {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn get_rent(&mut self) -> io::Result<Rent> {
|
||||||
|
let rent_sysvar = self
|
||||||
|
.get_account(sysvar::rent::id())
|
||||||
|
.await?
|
||||||
|
.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")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async fn get_recent_blockhash(&mut self) -> io::Result<Hash> {
|
async fn get_recent_blockhash(&mut self) -> io::Result<Hash> {
|
||||||
Ok(self.get_fees().await?.1)
|
Ok(self.get_fees().await?.1)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue