From 3b10f62e7faaa79eb0053f1f435481c34a00f7eb Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Thu, 18 Mar 2021 00:16:53 -0600 Subject: [PATCH] Apply review suggestions --- client/src/rpc_config.rs | 2 +- core/src/rpc.rs | 6 +++--- docs/src/developing/clients/jsonrpc-api.md | 10 +++++----- transaction-status/src/lib.rs | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/client/src/rpc_config.rs b/client/src/rpc_config.rs index 821aaf535f222f..f2af1beaa272e0 100644 --- a/client/src/rpc_config.rs +++ b/client/src/rpc_config.rs @@ -134,7 +134,7 @@ pub trait EncodingConfig { pub struct RpcConfirmedBlockConfig { pub encoding: Option, pub transaction_details: Option, - pub no_rewards: Option, + pub rewards: Option, } impl EncodingConfig for RpcConfirmedBlockConfig { diff --git a/core/src/rpc.rs b/core/src/rpc.rs index 0405fee0d6227a..325fa50702e156 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -726,7 +726,7 @@ impl JsonRpcRequestProcessor { .unwrap_or_default(); let encoding = config.encoding.unwrap_or(UiTransactionEncoding::Json); let transaction_details = config.transaction_details.unwrap_or_default(); - let show_rewards = !config.no_rewards.unwrap_or_default(); + let show_rewards = config.rewards.unwrap_or(true); if self.config.enable_rpc_transaction_history && slot <= self @@ -5176,7 +5176,7 @@ pub mod tests { json!(RpcConfirmedBlockConfig { encoding: None, transaction_details: Some(TransactionDetails::Signatures), - no_rewards: Some(true), + rewards: Some(false), }) ); let res = io.handle_request_sync(&req, meta.clone()); @@ -5196,7 +5196,7 @@ pub mod tests { json!(RpcConfirmedBlockConfig { encoding: None, transaction_details: Some(TransactionDetails::None), - no_rewards: Some(false), + rewards: Some(true), }) ); let res = io.handle_request_sync(&req, meta); diff --git a/docs/src/developing/clients/jsonrpc-api.md b/docs/src/developing/clients/jsonrpc-api.md index 83fab7dfe4b9d3..6786d099510215 100644 --- a/docs/src/developing/clients/jsonrpc-api.md +++ b/docs/src/developing/clients/jsonrpc-api.md @@ -460,8 +460,8 @@ Returns identity and transaction information about a confirmed block in the ledg - `` - (optional) Configuration object containing the following optional fields: - (optional) `encoding: ` - encoding for each returned Transaction, either "json", "jsonParsed", "base58" (*slow*), "base64". If parameter not provided, the default encoding is "json". "jsonParsed" encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the `transaction.message.instructions` list. If "jsonParsed" is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (`accounts`, `data`, and `programIdIndex` fields). - - (optional) `transactionDetails: ` - level of transaction detail to return, either "all", "signatures", or "none". If parameter not provided, the default detail level is "all". - - (optional) `noRewards: bool` - whether to skip returning rewards for epoch-boundary blocks. If parameter not provided, the default returns rewards. + - (optional) `transactionDetails: ` - level of transaction detail to return, either "full", "signatures", or "none". If parameter not provided, the default detail level is "full". + - (optional) `rewards: bool` - whether to populate the `rewards` array. If parameter not provided, the default includes rewards. #### Results: @@ -472,7 +472,7 @@ The result field will be an object with the following fields: - `blockhash: ` - the blockhash of this block, as base-58 encoded string - `previousBlockhash: ` - the blockhash of this block's parent, as base-58 encoded string; if the parent block is not available due to ledger cleanup, this field will return "11111111111111111111111111111111" - `parentSlot: ` - the slot index of this block's parent - - `transactions: ` - present if "all" transaction details are requested; an array of JSON objects containing: + - `transactions: ` - present if "full" transaction details are requested; an array of JSON objects containing: - `transaction: ` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter - `meta: ` - transaction status metadata object, containing `null` or: - `err: ` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://github.com/solana-labs/solana/blob/master/sdk/src/transaction.rs#L24) @@ -487,7 +487,7 @@ The result field will be an object with the following fields: - `"Ok": ` - Transaction was successful - `"Err": ` - Transaction failed with TransactionError - `signatures: ` - present if "signatures" are requested for transaction details; an array of signatures strings, corresponding to the transaction order in the block - - `rewards: ` - present if rewards are not suppressed; an array of JSON objects containing: + - `rewards: ` - present if rewards are requested; an array of JSON objects containing: - `pubkey: ` - The public key, as base-58 encoded string, of the account that received the reward - `lamports: `- number of reward lamports credited or debited by the account, as a i64 - `postBalance: ` - account balance in lamports after the reward was applied @@ -499,7 +499,7 @@ The result field will be an object with the following fields: Request: ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlock","params":[430, {"encoding": "json","transactionDetails":"all","noRewards":true}]} + {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlock","params":[430, {"encoding": "json","transactionDetails":"full","rewards":false}]} ' ``` diff --git a/transaction-status/src/lib.rs b/transaction-status/src/lib.rs index e6260cb4e5efcd..e5e2ac81b73df0 100644 --- a/transaction-status/src/lib.rs +++ b/transaction-status/src/lib.rs @@ -370,7 +370,7 @@ impl ConfirmedBlock { show_rewards: bool, ) -> UiConfirmedBlock { let (transactions, signatures) = match transaction_details { - TransactionDetails::All => ( + TransactionDetails::Full => ( Some( self.transactions .into_iter() @@ -449,14 +449,14 @@ impl From for UiConfirmedBlock { #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub enum TransactionDetails { - All, + Full, Signatures, None, } impl Default for TransactionDetails { fn default() -> Self { - Self::All + Self::Full } }