Skip to content

Commit 60504e5

Browse files
committed
feat(rpc): Include previous block production attempt in /status response
1 parent c4782a5 commit 60504e5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

node/src/rpc/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ pub struct RpcNodeStatus {
468468
pub snark_pool: RpcNodeStatusSnarkPool,
469469
pub transaction_pool: RpcNodeStatusTransactionPool,
470470
pub current_block_production_attempt: Option<BlockProductionAttempt>,
471+
pub previous_block_production_attempt: Option<BlockProductionAttempt>,
471472
pub peers: Vec<RpcPeerInfo>,
472473
pub resources_status: RpcNodeStatusResources,
473474
pub service_queues: Queues,

node/src/rpc_effectful/rpc_effectful_effects.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,10 +788,20 @@ fn compute_node_status<S: Service>(store: &mut Store<S>) -> RpcNodeStatus {
788788
height: b.height(),
789789
global_slot: b.global_slot(),
790790
};
791-
let current_block_production_attempt = store
791+
792+
let block_production_attempts = store
792793
.service
793794
.stats()
794-
.and_then(|stats| Some(stats.block_producer().collect_attempts().last()?.clone()));
795+
.map_or_else(Vec::new, |stats| stats.block_producer().collect_attempts());
796+
797+
let current_block_production_attempt = block_production_attempts.last().cloned();
798+
799+
let previous_block_production_attempt = block_production_attempts
800+
.len()
801+
.checked_sub(2)
802+
.and_then(|idx| block_production_attempts.get(idx))
803+
.cloned();
804+
795805
let status = RpcNodeStatus {
796806
chain_id,
797807
transition_frontier: RpcNodeStatusTransitionFrontier {
@@ -835,6 +845,7 @@ fn compute_node_status<S: Service>(store: &mut Store<S>) -> RpcNodeStatus {
835845
transaction_candidates: state.transaction_pool.candidates.transactions_count(),
836846
},
837847
current_block_production_attempt,
848+
previous_block_production_attempt,
838849
resources_status: RpcNodeStatusResources {
839850
p2p_malloc_size: {
840851
let mut set = BTreeSet::new();

0 commit comments

Comments
 (0)