* Use last_valid_block_height in services and client apps (#19163)
* Add deprecated tag to Bank::get_blockhash_last_valid_slot
* Update SendTransactionService to use last_valid_block_height
* Update solana-tokens to use last_valid_block_height
* Remove dangling file
* Update solana program to use last_valid_block_height
* Update Banks crates to use last_valid_block_height
(cherry picked from commit 5970083b4d)
# Conflicts:
# cli/src/program.rs
* Fix conflict
Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
59 lines
1.8 KiB
Rust
59 lines
1.8 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
use solana_sdk::{
|
|
account::Account,
|
|
clock::Slot,
|
|
commitment_config::CommitmentLevel,
|
|
fee_calculator::FeeCalculator,
|
|
hash::Hash,
|
|
pubkey::Pubkey,
|
|
signature::Signature,
|
|
transaction::{self, Transaction, TransactionError},
|
|
};
|
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
|
pub enum TransactionConfirmationStatus {
|
|
Processed,
|
|
Confirmed,
|
|
Finalized,
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
|
pub struct TransactionStatus {
|
|
pub slot: Slot,
|
|
pub confirmations: Option<usize>, // None = rooted
|
|
pub err: Option<TransactionError>,
|
|
pub confirmation_status: Option<TransactionConfirmationStatus>,
|
|
}
|
|
|
|
#[tarpc::service]
|
|
pub trait Banks {
|
|
async fn send_transaction_with_context(transaction: Transaction);
|
|
async fn get_fees_with_commitment_and_context(
|
|
commitment: CommitmentLevel,
|
|
) -> (FeeCalculator, Hash, Slot);
|
|
async fn get_transaction_status_with_context(signature: Signature)
|
|
-> Option<TransactionStatus>;
|
|
async fn get_slot_with_context(commitment: CommitmentLevel) -> Slot;
|
|
async fn get_block_height_with_context(commitment: CommitmentLevel) -> u64;
|
|
async fn process_transaction_with_commitment_and_context(
|
|
transaction: Transaction,
|
|
commitment: CommitmentLevel,
|
|
) -> Option<transaction::Result<()>>;
|
|
async fn get_account_with_commitment_and_context(
|
|
address: Pubkey,
|
|
commitment: CommitmentLevel,
|
|
) -> Option<Account>;
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
use tarpc::{client, transport};
|
|
|
|
#[test]
|
|
fn test_banks_client_new() {
|
|
let (client_transport, _server_transport) = transport::channel::unbounded();
|
|
BanksClient::new(client::Config::default(), client_transport);
|
|
}
|
|
}
|