From 03b213e296d2d8dcd3ecf13b9506f186cf89bea2 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 10 Jul 2020 11:02:27 -0700 Subject: [PATCH] Add block time placeholder to getConfirmedBlock (#10990) (cherry picked from commit 491f5ae61a6541853ef75a6b634832ddcbde4cb4) Co-authored-by: Michael Vines --- docs/src/apps/jsonrpc-api.md | 1 + ledger/src/blockstore.rs | 3 +++ transaction-status/src/lib.rs | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/src/apps/jsonrpc-api.md b/docs/src/apps/jsonrpc-api.md index 6b358fc20b..828a11fa78 100644 --- a/docs/src/apps/jsonrpc-api.md +++ b/docs/src/apps/jsonrpc-api.md @@ -314,6 +314,7 @@ The result field will be an object with the following fields: * `rewards: ` - 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 + * `blockTime: ` - estimated production time, as Unix timestamp (seconds since the Unix epoch). null if not available #### Example: diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index 9adfd4ffb4..792a0cb8ae 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -1633,6 +1633,7 @@ impl Blockstore { slot_transaction_iterator, ), rewards, + block_time: None, // See https://github.com/solana-labs/solana/issues/10089 }; return Ok(block); } @@ -5236,6 +5237,7 @@ pub mod tests { blockhash: blockhash.to_string(), previous_blockhash: Hash::default().to_string(), rewards: vec![], + block_time: None, }; // The previous_blockhash of `expected_block` is default because its parent slot is a // root, but empty of entries. This is special handling for snapshot root slots. @@ -5257,6 +5259,7 @@ pub mod tests { blockhash: blockhash.to_string(), previous_blockhash: blockhash.to_string(), rewards: vec![], + block_time: None, }; assert_eq!(confirmed_block, expected_block); diff --git a/transaction-status/src/lib.rs b/transaction-status/src/lib.rs index e3cd4d67b8..20635d7615 100644 --- a/transaction-status/src/lib.rs +++ b/transaction-status/src/lib.rs @@ -9,7 +9,7 @@ pub mod parse_instruction; use crate::{parse_accounts::parse_accounts, parse_instruction::parse}; use serde_json::Value; use solana_sdk::{ - clock::Slot, + clock::{Slot, UnixTimestamp}, commitment_config::CommitmentConfig, instruction::CompiledInstruction, message::MessageHeader, @@ -118,6 +118,7 @@ pub struct ConfirmedBlock { pub parent_slot: Slot, pub transactions: Vec, pub rewards: Rewards, + pub block_time: Option, } #[derive(Debug, PartialEq, Serialize, Deserialize)]