From dce7739b75953c21fd5d87c4052847f2d62f4402 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 10 Jul 2020 11:02:43 -0700 Subject: [PATCH] Add block time placeholder to getConfirmedBlock (#10989) (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 4b94a91d88..aedb557b8f 100644 --- a/docs/src/apps/jsonrpc-api.md +++ b/docs/src/apps/jsonrpc-api.md @@ -307,6 +307,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 352bfaefb5..3eed86d3b0 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -1649,6 +1649,7 @@ impl Blockstore { slot_transaction_iterator, ), rewards, + block_time: None, // See https://github.com/solana-labs/solana/issues/10089 }; return Ok(block); } @@ -5334,6 +5335,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. @@ -5355,6 +5357,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 fb42d20748..1a9c612489 100644 --- a/transaction-status/src/lib.rs +++ b/transaction-status/src/lib.rs @@ -2,7 +2,7 @@ extern crate serde_derive; use solana_sdk::{ - clock::Slot, + clock::{Slot, UnixTimestamp}, commitment_config::CommitmentConfig, message::MessageHeader, transaction::{Result, Transaction, TransactionError}, @@ -91,6 +91,7 @@ pub struct ConfirmedBlock { pub parent_slot: Slot, pub transactions: Vec, pub rewards: Rewards, + pub block_time: Option, } #[derive(Debug, PartialEq, Serialize, Deserialize)]