Add block time placeholder to getConfirmedBlock (#10989)

(cherry picked from commit 491f5ae61a)

Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
mergify[bot]
2020-07-10 11:02:43 -07:00
committed by GitHub
parent 1c703af6a2
commit dce7739b75
3 changed files with 6 additions and 1 deletions

View File

@ -307,6 +307,7 @@ The result field will be an object with the following fields:
* `rewards: <array>` - an array of JSON objects containing:
* `pubkey: <string>` - The public key, as base-58 encoded string, of the account that received the reward
* `lamports: <i64>`- number of reward lamports credited or debited by the account, as a i64
* `blockTime: <i64 | null>` - estimated production time, as Unix timestamp (seconds since the Unix epoch). null if not available
#### Example:

View File

@ -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);

View File

@ -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<TransactionWithStatusMeta>,
pub rewards: Rewards,
pub block_time: Option<UnixTimestamp>,
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]