@@ -12,9 +12,9 @@ use crate::{
1212 p2p_ready,
1313 rpc:: {
1414 AccountQuery , AccountSlim , ActionStatsQuery , ActionStatsResponse , CurrentMessageProgress ,
15- MessagesStats , NodeHeartbeat , RootLedgerSyncProgress , RootStagedLedgerSyncProgress ,
16- RpcAction , RpcBlockProducerStats , RpcMessageProgressResponse , RpcNodeStatus ,
17- RpcNodeStatusLedger , RpcNodeStatusResources , RpcNodeStatusTransactionPool ,
15+ MessagesStats , NodeHeartbeat , ProducedBlockInfo , RootLedgerSyncProgress ,
16+ RootStagedLedgerSyncProgress , RpcAction , RpcBlockProducerStats , RpcMessageProgressResponse ,
17+ RpcNodeStatus , RpcNodeStatusLedger , RpcNodeStatusResources , RpcNodeStatusTransactionPool ,
1818 RpcNodeStatusTransitionFrontier , RpcNodeStatusTransitionFrontierBlockSummary ,
1919 RpcNodeStatusTransitionFrontierSync , RpcRequestExtraData , RpcScanStateSummary ,
2020 RpcScanStateSummaryBlock , RpcScanStateSummaryBlockTransaction ,
@@ -70,10 +70,12 @@ pub fn rpc_effects<S: Service>(store: &mut Store<S>, action: ActionWithMeta<RpcE
7070 . stats ( )
7171 . and_then ( |stats| stats. block_producer ( ) . last_produced_block . take ( ) ) ;
7272
73- let last_produced_block = match base64_encode_block ( last_produced_block) {
74- Ok ( block ) => block ,
73+ let last_produced_block_info = match make_produced_block_info ( last_produced_block) {
74+ Ok ( data ) => data ,
7575 Err ( error) => {
76- bug_condition ! ( "HeartbeatGet: Failed to encode block, returning None: {error}" ) ;
76+ bug_condition ! (
77+ "HeartbeatGet: Failed to encode block header, returning None: {error}"
78+ ) ;
7779 None
7880 }
7981 } ;
@@ -82,7 +84,7 @@ pub fn rpc_effects<S: Service>(store: &mut Store<S>, action: ActionWithMeta<RpcE
8284 status : status. into ( ) ,
8385 node_timestamp : meta. time ( ) ,
8486 peer_id : store. state ( ) . p2p . my_id ( ) ,
85- last_produced_block ,
87+ last_produced_block_info ,
8688 } ;
8789 let response = store
8890 . service ( )
@@ -841,16 +843,26 @@ fn compute_node_status<S: Service>(store: &mut Store<S>) -> RpcNodeStatus {
841843 status
842844}
843845
844- fn base64_encode_block ( block : Option < ArcBlockWithHash > ) -> std:: io:: Result < Option < String > > {
846+ fn make_produced_block_info (
847+ block : Option < ArcBlockWithHash > ,
848+ ) -> std:: io:: Result < Option < ProducedBlockInfo > > {
845849 use base64:: { engine:: general_purpose:: URL_SAFE , Engine as _} ;
846850 use mina_p2p_messages:: binprot:: BinProtWrite ;
847851
848852 let Some ( block) = block else { return Ok ( None ) } ;
849853
850- let mut buf = Vec :: with_capacity ( 10 * 1024 * 1024 ) ;
851- v2:: MinaBlockBlockStableV2 :: binprot_write ( & block. block , & mut buf) ?;
854+ let height = block. height ( ) ;
855+ let global_slot = block. global_slot ( ) ;
856+ let hash = block. hash ( ) . to_string ( ) ;
857+ let mut buf = Vec :: with_capacity ( 5 * 1024 * 1024 ) ;
858+ v2:: MinaBlockHeaderStableV2 :: binprot_write ( block. header ( ) , & mut buf) ?;
852859
853- let base64_encoded = URL_SAFE . encode ( & buf) ;
860+ let base64_encoded_header = URL_SAFE . encode ( & buf) ;
854861
855- Ok ( Some ( base64_encoded) )
862+ Ok ( Some ( ProducedBlockInfo {
863+ height,
864+ global_slot,
865+ hash,
866+ base64_encoded_header,
867+ } ) )
856868}
0 commit comments