@@ -17,10 +17,11 @@ use crate::{
1717 RpcTransactionInjectResponse , TransactionStatus ,
1818 } ,
1919 snark_pool:: SnarkPoolAction ,
20+ stats:: block_producer:: BlockProductionAttemptWonSlot ,
2021 transition_frontier:: sync:: {
2122 ledger:: TransitionFrontierSyncLedgerState , TransitionFrontierSyncState ,
2223 } ,
23- Service , Store ,
24+ Service , State , Store ,
2425} ;
2526use ledger:: {
2627 scan_state:: currency:: { Balance , Magnitude } ,
@@ -46,6 +47,15 @@ macro_rules! respond_or_log {
4647 } ;
4748}
4849
50+ fn get_next_won_slot ( state : & State ) -> Option < BlockProductionAttemptWonSlot > {
51+ let best_tip = state. transition_frontier . best_tip ( ) ?;
52+ let vrf = state. block_producer . vrf_evaluator ( ) ?;
53+ let ( _, won_slot) = vrf. won_slots . first_key_value ( ) ?;
54+
55+ let won_slot = BlockProducerWonSlot :: from_vrf_won_slot ( won_slot, best_tip. genesis_timestamp ( ) ) ;
56+ Some ( ( & won_slot) . into ( ) )
57+ }
58+
4959pub fn rpc_effects < S : Service > ( store : & mut Store < S > , action : ActionWithMeta < RpcEffectfulAction > ) {
5060 let ( action, meta) = action. split ( ) ;
5161
@@ -64,6 +74,7 @@ pub fn rpc_effects<S: Service>(store: &mut Store<S>, action: ActionWithMeta<RpcE
6474 height : b. height ( ) ,
6575 global_slot : b. global_slot ( ) ,
6676 } ;
77+ let next_won_slot = get_next_won_slot ( state) ;
6778 let status = RpcNodeStatus {
6879 chain_id,
6980 transition_frontier : RpcNodeStatusTransitionFrontier {
@@ -89,6 +100,7 @@ pub fn rpc_effects<S: Service>(store: &mut Store<S>, action: ActionWithMeta<RpcE
89100 transaction_pool : RpcNodeStatusTransactionPool {
90101 transactions : state. transaction_pool . size ( ) ,
91102 } ,
103+ next_won_slot,
92104 } ;
93105 let _ = store. service . respond_status_get ( rpc_id, Some ( status) ) ;
94106 }
0 commit comments