Skip to content

Commit

Permalink
Update struct prefixes to Ui (solana-labs#10874)
Browse files Browse the repository at this point in the history
* Update comments

* Use Ui prefix
  • Loading branch information
CriesofCarrots authored and Tyera Eulberg committed Jul 7, 2020
1 parent 370a457 commit e07e3cb
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 66 deletions.
4 changes: 2 additions & 2 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use solana_stake_program::{
stake_instruction::LockupArgs,
stake_state::{Lockup, StakeAuthorize},
};
use solana_transaction_status::{EncodedTransaction, TransactionEncoding};
use solana_transaction_status::{EncodedTransaction, UiTransactionEncoding};
use solana_vote_program::vote_state::VoteAuthorize;
use std::{
error,
Expand Down Expand Up @@ -1174,7 +1174,7 @@ fn process_confirm(
if let Some(transaction_status) = status {
if config.verbose {
match rpc_client
.get_confirmed_transaction(signature, TransactionEncoding::Binary)
.get_confirmed_transaction(signature, UiTransactionEncoding::Binary)
{
Ok(confirmed_transaction) => {
println!(
Expand Down
6 changes: 3 additions & 3 deletions cli/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use solana_sdk::{
hash::Hash, native_token::lamports_to_sol, program_utils::limited_deserialize,
transaction::Transaction,
};
use solana_transaction_status::RpcTransactionStatusMeta;
use solana_transaction_status::UiTransactionStatusMeta;
use std::{fmt, io};

// Pretty print a "name value"
Expand Down Expand Up @@ -68,7 +68,7 @@ pub fn println_signers(
pub fn write_transaction<W: io::Write>(
w: &mut W,
transaction: &Transaction,
transaction_status: &Option<RpcTransactionStatusMeta>,
transaction_status: &Option<UiTransactionStatusMeta>,
prefix: &str,
) -> io::Result<()> {
let message = &transaction.message;
Expand Down Expand Up @@ -191,7 +191,7 @@ pub fn write_transaction<W: io::Write>(

pub fn println_transaction(
transaction: &Transaction,
transaction_status: &Option<RpcTransactionStatusMeta>,
transaction_status: &Option<UiTransactionStatusMeta>,
prefix: &str,
) {
let mut w = Vec::new();
Expand Down
8 changes: 4 additions & 4 deletions client/src/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use solana_sdk::{
transaction::{self, Transaction},
};
use solana_transaction_status::{
ConfirmedBlock, ConfirmedTransaction, TransactionEncoding, TransactionStatus,
ConfirmedBlock, ConfirmedTransaction, TransactionStatus, UiTransactionEncoding,
};
use solana_vote_program::vote_state::MAX_LOCKOUT_HISTORY;
use std::{
Expand Down Expand Up @@ -239,13 +239,13 @@ impl RpcClient {
}

pub fn get_confirmed_block(&self, slot: Slot) -> ClientResult<ConfirmedBlock> {
self.get_confirmed_block_with_encoding(slot, TransactionEncoding::Json)
self.get_confirmed_block_with_encoding(slot, UiTransactionEncoding::Json)
}

pub fn get_confirmed_block_with_encoding(
&self,
slot: Slot,
encoding: TransactionEncoding,
encoding: UiTransactionEncoding,
) -> ClientResult<ConfirmedBlock> {
self.send(RpcRequest::GetConfirmedBlock, json!([slot, encoding]))
}
Expand Down Expand Up @@ -286,7 +286,7 @@ impl RpcClient {
pub fn get_confirmed_transaction(
&self,
signature: &Signature,
encoding: TransactionEncoding,
encoding: UiTransactionEncoding,
) -> ClientResult<ConfirmedTransaction> {
self.send(
RpcRequest::GetConfirmedTransaction,
Expand Down
20 changes: 10 additions & 10 deletions core/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use solana_sdk::{
};
use solana_stake_program::stake_state::StakeState;
use solana_transaction_status::{
ConfirmedBlock, ConfirmedTransaction, TransactionEncoding, TransactionStatus,
ConfirmedBlock, ConfirmedTransaction, TransactionStatus, UiTransactionEncoding,
};
use solana_vote_program::vote_state::{VoteState, MAX_LOCKOUT_HISTORY};
use std::{
Expand Down Expand Up @@ -494,7 +494,7 @@ impl JsonRpcRequestProcessor {
pub fn get_confirmed_block(
&self,
slot: Slot,
encoding: Option<TransactionEncoding>,
encoding: Option<UiTransactionEncoding>,
) -> Result<Option<ConfirmedBlock>> {
if self.config.enable_rpc_transaction_history
&& slot
Expand Down Expand Up @@ -663,7 +663,7 @@ impl JsonRpcRequestProcessor {
pub fn get_confirmed_transaction(
&self,
signature: Signature,
encoding: Option<TransactionEncoding>,
encoding: Option<UiTransactionEncoding>,
) -> Result<Option<ConfirmedTransaction>> {
if self.config.enable_rpc_transaction_history {
Ok(self
Expand Down Expand Up @@ -1037,7 +1037,7 @@ pub trait RpcSol {
&self,
meta: Self::Metadata,
slot: Slot,
encoding: Option<TransactionEncoding>,
encoding: Option<UiTransactionEncoding>,
) -> Result<Option<ConfirmedBlock>>;

#[rpc(meta, name = "getBlockTime")]
Expand All @@ -1056,7 +1056,7 @@ pub trait RpcSol {
&self,
meta: Self::Metadata,
signature_str: String,
encoding: Option<TransactionEncoding>,
encoding: Option<UiTransactionEncoding>,
) -> Result<Option<ConfirmedTransaction>>;

#[rpc(meta, name = "getConfirmedSignaturesForAddress")]
Expand Down Expand Up @@ -1535,7 +1535,7 @@ impl RpcSol for RpcSolImpl {
&self,
meta: Self::Metadata,
slot: Slot,
encoding: Option<TransactionEncoding>,
encoding: Option<UiTransactionEncoding>,
) -> Result<Option<ConfirmedBlock>> {
meta.get_confirmed_block(slot, encoding)
}
Expand All @@ -1557,7 +1557,7 @@ impl RpcSol for RpcSolImpl {
&self,
meta: Self::Metadata,
signature_str: String,
encoding: Option<TransactionEncoding>,
encoding: Option<UiTransactionEncoding>,
) -> Result<Option<ConfirmedTransaction>> {
let signature = verify_signature(&signature_str)?;
meta.get_confirmed_transaction(signature, encoding)
Expand Down Expand Up @@ -1665,7 +1665,7 @@ pub mod tests {
system_transaction,
transaction::{self, TransactionError},
};
use solana_transaction_status::{EncodedTransaction, RpcMessage, TransactionWithStatusMeta};
use solana_transaction_status::{EncodedTransaction, TransactionWithStatusMeta, UiMessage};
use solana_vote_program::{
vote_instruction,
vote_state::{Vote, VoteInit, MAX_LOCKOUT_HISTORY},
Expand Down Expand Up @@ -3230,8 +3230,8 @@ pub mod tests {
if transaction.signatures[0] == confirmed_block_signatures[0].to_string() {
let meta = meta.unwrap();
let transaction_recent_blockhash = match transaction.message {
RpcMessage::Parsed(message) => message.recent_blockhash,
RpcMessage::Raw(message) => message.recent_blockhash,
UiMessage::Parsed(message) => message.recent_blockhash,
UiMessage::Raw(message) => message.recent_blockhash,
};
assert_eq!(transaction_recent_blockhash, blockhash.to_string());
assert_eq!(meta.status, Ok(()));
Expand Down
28 changes: 14 additions & 14 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ use solana_sdk::{
transaction::Transaction,
};
use solana_transaction_status::{
ConfirmedBlock, ConfirmedTransaction, EncodedTransaction, Rewards, RpcTransactionStatusMeta,
TransactionEncoding, TransactionStatusMeta, TransactionWithStatusMeta,
ConfirmedBlock, ConfirmedTransaction, EncodedTransaction, Rewards, TransactionStatusMeta,
TransactionWithStatusMeta, UiTransactionEncoding, UiTransactionStatusMeta,
};
use solana_vote_program::{vote_instruction::VoteInstruction, vote_state::TIMESTAMP_SLOT_INTERVAL};
use std::{
Expand Down Expand Up @@ -1580,7 +1580,7 @@ impl Blockstore {
pub fn get_confirmed_block(
&self,
slot: Slot,
encoding: Option<TransactionEncoding>,
encoding: Option<UiTransactionEncoding>,
) -> Result<ConfirmedBlock> {
datapoint_info!(
"blockstore-rpc-api",
Expand All @@ -1592,7 +1592,7 @@ impl Blockstore {
if *lowest_cleanup_slot > 0 && *lowest_cleanup_slot >= slot {
return Err(BlockstoreError::SlotCleanedUp);
}
let encoding = encoding.unwrap_or(TransactionEncoding::Json);
let encoding = encoding.unwrap_or(UiTransactionEncoding::Json);
if self.is_root(slot) {
let slot_meta_cf = self.db.column::<cf::SlotMeta>();
let slot_meta = match slot_meta_cf.get(slot)? {
Expand Down Expand Up @@ -1643,7 +1643,7 @@ impl Blockstore {
fn map_transactions_to_statuses<'a>(
&self,
slot: Slot,
encoding: TransactionEncoding,
encoding: UiTransactionEncoding,
iterator: impl Iterator<Item = Transaction> + 'a,
) -> Vec<TransactionWithStatusMeta> {
iterator
Expand All @@ -1655,7 +1655,7 @@ impl Blockstore {
meta: self
.read_transaction_status((signature, slot))
.expect("Expect database get to succeed")
.map(RpcTransactionStatusMeta::from),
.map(UiTransactionStatusMeta::from),
}
})
.collect()
Expand Down Expand Up @@ -1825,7 +1825,7 @@ impl Blockstore {
pub fn get_confirmed_transaction(
&self,
signature: Signature,
encoding: Option<TransactionEncoding>,
encoding: Option<UiTransactionEncoding>,
) -> Result<Option<ConfirmedTransaction>> {
datapoint_info!(
"blockstore-rpc-api",
Expand All @@ -1834,7 +1834,7 @@ impl Blockstore {
if let Some((slot, status)) = self.get_transaction_status(signature.clone())? {
let transaction = self.find_transaction_in_slot(slot, signature)?
.expect("Transaction to exist in slot entries if it exists in statuses and hasn't been cleaned up");
let encoding = encoding.unwrap_or(TransactionEncoding::Json);
let encoding = encoding.unwrap_or(UiTransactionEncoding::Json);
let encoded_transaction = EncodedTransaction::encode(transaction, encoding);
Ok(Some(ConfirmedTransaction {
slot,
Expand Down Expand Up @@ -5164,7 +5164,7 @@ pub mod tests {
.put_meta_bytes(slot - 1, &serialize(&parent_meta).unwrap())
.unwrap();

let expected_transactions: Vec<(Transaction, Option<RpcTransactionStatusMeta>)> = entries
let expected_transactions: Vec<(Transaction, Option<UiTransactionStatusMeta>)> = entries
.iter()
.cloned()
.filter(|entry| !entry.is_tick())
Expand Down Expand Up @@ -5228,7 +5228,7 @@ pub mod tests {
.iter()
.cloned()
.map(|(tx, meta)| TransactionWithStatusMeta {
transaction: EncodedTransaction::encode(tx, TransactionEncoding::Json),
transaction: EncodedTransaction::encode(tx, UiTransactionEncoding::Json),
meta,
})
.collect(),
Expand All @@ -5249,7 +5249,7 @@ pub mod tests {
.iter()
.cloned()
.map(|(tx, meta)| TransactionWithStatusMeta {
transaction: EncodedTransaction::encode(tx, TransactionEncoding::Json),
transaction: EncodedTransaction::encode(tx, UiTransactionEncoding::Json),
meta,
})
.collect(),
Expand Down Expand Up @@ -5866,7 +5866,7 @@ pub mod tests {
blockstore.insert_shreds(shreds, None, false).unwrap();
blockstore.set_roots(&[slot - 1, slot]).unwrap();

let expected_transactions: Vec<(Transaction, Option<RpcTransactionStatusMeta>)> = entries
let expected_transactions: Vec<(Transaction, Option<UiTransactionStatusMeta>)> = entries
.iter()
.cloned()
.filter(|entry| !entry.is_tick())
Expand Down Expand Up @@ -5909,7 +5909,7 @@ pub mod tests {
for (transaction, status) in expected_transactions.clone() {
let signature = transaction.signatures[0];
let encoded_transaction =
EncodedTransaction::encode(transaction, TransactionEncoding::Json);
EncodedTransaction::encode(transaction, UiTransactionEncoding::Json);
let expected_transaction = ConfirmedTransaction {
slot,
transaction: TransactionWithStatusMeta {
Expand Down Expand Up @@ -6137,7 +6137,7 @@ pub mod tests {

let map = blockstore.map_transactions_to_statuses(
slot,
TransactionEncoding::Json,
UiTransactionEncoding::Json,
transactions.into_iter(),
);
assert_eq!(map.len(), 5);
Expand Down
6 changes: 3 additions & 3 deletions stake-monitor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use solana_sdk::{
pubkey::Pubkey, signature::Signature, transaction::Transaction,
};
use solana_stake_program::{stake_instruction::StakeInstruction, stake_state::Lockup};
use solana_transaction_status::{ConfirmedBlock, RpcTransactionStatusMeta, TransactionEncoding};
use solana_transaction_status::{ConfirmedBlock, UiTransactionEncoding, UiTransactionStatusMeta};
use std::{collections::HashMap, thread::sleep, time::Duration};

pub type PubkeyString = String;
Expand Down Expand Up @@ -65,7 +65,7 @@ impl AccountsInfo {
fn process_transaction(
slot: Slot,
transaction: &Transaction,
meta: &RpcTransactionStatusMeta,
meta: &UiTransactionStatusMeta,
accounts: &mut HashMap<PubkeyString, AccountInfo>,
) {
let mut last_instruction = true;
Expand Down Expand Up @@ -289,7 +289,7 @@ fn load_blocks(
let mut blocks = vec![];
for slot in slots.into_iter() {
let block =
rpc_client.get_confirmed_block_with_encoding(slot, TransactionEncoding::Binary)?;
rpc_client.get_confirmed_block_with_encoding(slot, UiTransactionEncoding::Binary)?;
blocks.push((slot, block));
}
Ok(blocks)
Expand Down
Loading

0 comments on commit e07e3cb

Please sign in to comment.