@@ -6,7 +6,7 @@ use p2p::{
66use redux:: ActionWithMeta ;
77
88use crate :: {
9- ledger:: read:: { LedgerReadAction , LedgerReadRequest } ,
9+ ledger:: read:: { LedgerReadAction , LedgerReadRequest , PropagateLedgerReadInit } ,
1010 p2p_ready,
1111 rpc_effectful:: RpcEffectfulAction ,
1212 TransactionPoolAction ,
@@ -83,12 +83,20 @@ impl RpcState {
8383 }
8484 RpcAction :: P2pConnectionOutgoingPending { rpc_id } => {
8585 let Some ( rpc) = state. requests . get_mut ( rpc_id) else {
86+ bug_condition ! (
87+ "Rpc state not found for RpcAction::P2pConnectionOutgoingPending({})" ,
88+ rpc_id
89+ ) ;
8690 return ;
8791 } ;
8892 rpc. status = RpcRequestStatus :: Pending { time : meta. time ( ) } ;
8993 }
9094 RpcAction :: P2pConnectionOutgoingError { rpc_id, error } => {
9195 let Some ( rpc) = state. requests . get_mut ( rpc_id) else {
96+ bug_condition ! (
97+ "Rpc state not found for RpcAction::P2pConnectionOutgoingError({})" ,
98+ rpc_id
99+ ) ;
92100 return ;
93101 } ;
94102 rpc. status = RpcRequestStatus :: Error {
@@ -104,6 +112,10 @@ impl RpcState {
104112 }
105113 RpcAction :: P2pConnectionOutgoingSuccess { rpc_id } => {
106114 let Some ( rpc) = state. requests . get_mut ( rpc_id) else {
115+ bug_condition ! (
116+ "Rpc state not found for RpcAction::P2pConnectionOutgoingSuccess({})" ,
117+ rpc_id
118+ ) ;
107119 return ;
108120 } ;
109121 rpc. status = RpcRequestStatus :: Success { time : meta. time ( ) } ;
@@ -142,6 +154,10 @@ impl RpcState {
142154 }
143155 RpcAction :: P2pConnectionIncomingPending { rpc_id } => {
144156 let Some ( rpc) = state. requests . get_mut ( rpc_id) else {
157+ bug_condition ! (
158+ "Rpc state not found for RpcAction::P2pConnectionIncomingPending({})" ,
159+ rpc_id
160+ ) ;
145161 return ;
146162 } ;
147163 rpc. status = RpcRequestStatus :: Pending { time : meta. time ( ) } ;
@@ -155,6 +171,10 @@ impl RpcState {
155171 }
156172 RpcAction :: P2pConnectionIncomingError { rpc_id, error } => {
157173 let Some ( rpc) = state. requests . get_mut ( rpc_id) else {
174+ bug_condition ! (
175+ "Rpc state not found for RpcAction::P2pConnectionIncomingError({})" ,
176+ rpc_id
177+ ) ;
158178 return ;
159179 } ;
160180 rpc. status = RpcRequestStatus :: Error {
@@ -170,6 +190,10 @@ impl RpcState {
170190 }
171191 RpcAction :: P2pConnectionIncomingSuccess { rpc_id } => {
172192 let Some ( rpc) = state. requests . get_mut ( rpc_id) else {
193+ bug_condition ! (
194+ "Rpc state not found for RpcAction::P2pConnectionIncomingSuccess({})" ,
195+ rpc_id
196+ ) ;
173197 return ;
174198 } ;
175199 rpc. status = RpcRequestStatus :: Success { time : meta. time ( ) } ;
@@ -232,31 +256,33 @@ impl RpcState {
232256 }
233257 } ;
234258
235- // TODO: add callbacks here
236- if dispatcher. push_if_enabled (
237- LedgerReadAction :: Init {
238- request : LedgerReadRequest :: ScanStateSummary (
239- block. staged_ledger_hashes ( ) . clone ( ) ,
240- ) ,
241- } ,
242- state,
243- meta. time ( ) ,
244- ) {
245- dispatcher. push ( RpcAction :: ScanStateSummaryGetPending {
259+ dispatcher. push ( LedgerReadAction :: Init {
260+ request : LedgerReadRequest :: ScanStateSummary (
261+ block. staged_ledger_hashes ( ) . clone ( ) ,
262+ ) ,
263+ propagate : Some ( PropagateLedgerReadInit :: RpcScanStateSummaryGetPending {
246264 rpc_id : * rpc_id,
247- block : Some ( block ) ,
248- } ) ;
249- }
265+ block,
266+ } ) ,
267+ } ) ;
250268 }
251269 RpcAction :: ScanStateSummaryGetPending { rpc_id, block } => {
252270 let Some ( rpc) = state. requests . get_mut ( rpc_id) else {
271+ bug_condition ! (
272+ "Rpc state not found for RpcAction::ScanStateSummaryGetPending({})" ,
273+ rpc_id
274+ ) ;
253275 return ;
254276 } ;
255277 rpc. status = RpcRequestStatus :: Pending { time : meta. time ( ) } ;
256278 rpc. data = RpcRequestExtraData :: FullBlockOpt ( block. clone ( ) ) ;
257279 }
258280 RpcAction :: ScanStateSummaryGetSuccess { rpc_id, scan_state } => {
259281 let Some ( rpc) = state. requests . get_mut ( rpc_id) else {
282+ bug_condition ! (
283+ "Rpc state not found for RpcAction::ScanStateSummaryGetSuccess({})" ,
284+ rpc_id
285+ ) ;
260286 return ;
261287 } ;
262288 rpc. status = RpcRequestStatus :: Success { time : meta. time ( ) } ;
@@ -408,20 +434,16 @@ impl RpcState {
408434 return ;
409435 } ;
410436
411- // TODO: add callback here
412- if dispatcher. push_if_enabled (
413- LedgerReadAction :: Init {
414- request : LedgerReadRequest :: AccountsForRpc (
415- * rpc_id,
416- ledger_hash. clone ( ) ,
417- account_query. clone ( ) ,
418- ) ,
419- } ,
420- state,
421- meta. time ( ) ,
422- ) {
423- dispatcher. push ( RpcAction :: LedgerAccountsGetPending { rpc_id : * rpc_id } ) ;
424- }
437+ dispatcher. push ( LedgerReadAction :: Init {
438+ request : LedgerReadRequest :: AccountsForRpc (
439+ * rpc_id,
440+ ledger_hash. clone ( ) ,
441+ account_query. clone ( ) ,
442+ ) ,
443+ propagate : Some ( PropagateLedgerReadInit :: RpcLedgerAccountsGetPending {
444+ rpc_id : * rpc_id,
445+ } ) ,
446+ } )
425447 }
426448 RpcAction :: LedgerAccountsGetPending { rpc_id } => {
427449 let Some ( rpc) = state. requests . get_mut ( rpc_id) else {
0 commit comments