From 6fbad244772862200e8a966570e7c689467d170b Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Tue, 21 Jul 2020 14:43:48 -0700 Subject: [PATCH] getEpochInfo RPC endpoint now includes the current block height --- client/src/rpc_response.rs | 3 +++ core/src/rpc.rs | 2 ++ docs/src/apps/jsonrpc-api.md | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/client/src/rpc_response.rs b/client/src/rpc_response.rs index a8be5ca652..1ba4c0ede0 100644 --- a/client/src/rpc_response.rs +++ b/client/src/rpc_response.rs @@ -169,6 +169,9 @@ pub struct RpcEpochInfo { /// The absolute current slot pub absolute_slot: Slot, + + /// The current block height + pub block_height: u64, } #[derive(Serialize, Deserialize, Clone, Debug)] diff --git a/core/src/rpc.rs b/core/src/rpc.rs index cb9d3a3df2..b9a745a9af 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -1188,12 +1188,14 @@ impl RpcSol for RpcSolImpl { let epoch_schedule = bank.epoch_schedule(); let slot = bank.slot(); + let block_height = bank.block_height(); let (epoch, slot_index) = epoch_schedule.get_epoch_and_slot_index(slot); Ok(RpcEpochInfo { epoch, slot_index, slots_in_epoch: epoch_schedule.get_slots_in_epoch(epoch), absolute_slot: slot, + block_height, }) } diff --git a/docs/src/apps/jsonrpc-api.md b/docs/src/apps/jsonrpc-api.md index dc4bd6a362..b4e3ac3581 100644 --- a/docs/src/apps/jsonrpc-api.md +++ b/docs/src/apps/jsonrpc-api.md @@ -451,6 +451,7 @@ Returns information about the current epoch The result field will be an object with the following fields: * `absoluteSlot: `, the current slot +* `blockHeight: `, the current block height * `epoch: `, the current epoch * `slotIndex: `, the current slot relative to the start of the current epoch * `slotsInEpoch: `, the number of slots in this epoch @@ -462,7 +463,7 @@ The result field will be an object with the following fields: curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1, "method":"getEpochInfo"}' http://localhost:8899 // Result -{"jsonrpc":"2.0","result":{"absoluteSlot":166598,"epoch":27,"slotIndex":2790,"slotsInEpoch":8192},"id":1} +{"jsonrpc":"2.0","result":{"absoluteSlot":166598,"blockHeight": 166500, "epoch":27,"slotIndex":2790,"slotsInEpoch":8192},"id":1} ``` ### getEpochSchedule