Skip to content

Commit 014dd4f

Browse files
authored
Merge pull request #912 from openmina/fix/producer-status-rpc
fix(rpc): Replace `next_won_slot` in `/status` with `current_block_production_attempt`
2 parents 68357e0 + b0c6f0f commit 014dd4f

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

node/src/rpc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ pub struct RpcNodeStatus {
453453
pub peers: Vec<RpcPeerInfo>,
454454
pub snark_pool: RpcNodeStatusSnarkPool,
455455
pub transaction_pool: RpcNodeStatusTransactionPool,
456-
pub next_won_slot: Option<BlockProductionAttemptWonSlot>,
456+
pub current_block_production_attempt: Option<BlockProductionAttempt>,
457457
}
458458

459459
#[derive(Serialize, Debug, Clone)]

node/src/rpc_effectful/rpc_effectful_effects.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ use crate::{
1717
RpcTransactionInjectResponse, TransactionStatus,
1818
},
1919
snark_pool::SnarkPoolAction,
20-
stats::block_producer::BlockProductionAttemptWonSlot,
2120
transition_frontier::sync::{
2221
ledger::TransitionFrontierSyncLedgerState, TransitionFrontierSyncState,
2322
},
24-
Service, State, Store,
23+
Service, Store,
2524
};
2625
use ledger::{
2726
scan_state::currency::{Balance, Magnitude},
@@ -47,14 +46,6 @@ macro_rules! respond_or_log {
4746
};
4847
}
4948

50-
fn get_next_won_slot(state: &State) -> Option<BlockProductionAttemptWonSlot> {
51-
let best_tip = state.transition_frontier.best_tip()?;
52-
let cur_global_slot = state.cur_global_slot()?;
53-
let vrf = state.block_producer.vrf_evaluator()?;
54-
let won_slot = vrf.next_won_slot(cur_global_slot, best_tip)?;
55-
Some((&won_slot).into())
56-
}
57-
5849
pub fn rpc_effects<S: Service>(store: &mut Store<S>, action: ActionWithMeta<RpcEffectfulAction>) {
5950
let (action, meta) = action.split();
6051

@@ -73,7 +64,10 @@ pub fn rpc_effects<S: Service>(store: &mut Store<S>, action: ActionWithMeta<RpcE
7364
height: b.height(),
7465
global_slot: b.global_slot(),
7566
};
76-
let next_won_slot = get_next_won_slot(state);
67+
let current_block_production_attempt = store
68+
.service
69+
.stats()
70+
.and_then(|stats| Some(stats.block_producer().collect_attempts().last()?.clone()));
7771
let status = RpcNodeStatus {
7872
chain_id,
7973
transition_frontier: RpcNodeStatusTransitionFrontier {
@@ -99,7 +93,7 @@ pub fn rpc_effects<S: Service>(store: &mut Store<S>, action: ActionWithMeta<RpcE
9993
transaction_pool: RpcNodeStatusTransactionPool {
10094
transactions: state.transaction_pool.size(),
10195
},
102-
next_won_slot,
96+
current_block_production_attempt,
10397
};
10498
let _ = store.service.respond_status_get(rpc_id, Some(status));
10599
}

0 commit comments

Comments
 (0)