1
- use raiko_reqactor:: { Action , Actor } ;
1
+ use raiko_reqactor:: Actor ;
2
2
use raiko_reqpool:: {
3
3
AggregationRequestEntity , AggregationRequestKey , RequestEntity , RequestKey ,
4
4
SingleProofRequestKey , Status ,
@@ -13,18 +13,19 @@ pub async fn prove(
13
13
request_key : RequestKey ,
14
14
request_entity : RequestEntity ,
15
15
) -> Result < Status , String > {
16
- let action = Action :: Prove {
17
- request_key,
18
- request_entity,
19
- start_time : chrono:: Utc :: now ( ) ,
20
- } ;
21
- act ( actor, action) . await
16
+ if actor. is_paused ( ) {
17
+ return Err ( "System is paused" . to_string ( ) ) ;
18
+ }
19
+
20
+ actor
21
+ . act ( request_key. clone ( ) , request_entity, chrono:: Utc :: now ( ) )
22
+ . await
23
+ . map ( |status| status. into_status ( ) )
22
24
}
23
25
24
26
/// Cancel the request.
25
- pub async fn cancel ( actor : & Actor , request_key : RequestKey ) -> Result < Status , String > {
26
- let action = Action :: Cancel { request_key } ;
27
- act ( actor, action) . await
27
+ pub async fn cancel ( _actor : & Actor , _request_key : RequestKey ) -> Result < Status , String > {
28
+ unimplemented ! ( )
28
29
}
29
30
30
31
/// Prove the aggregation request and its sub-requests.
@@ -95,43 +96,3 @@ pub async fn cancel_aggregation(
95
96
}
96
97
cancel ( actor, request_key. into ( ) ) . await
97
98
}
98
-
99
- // === Helper functions ===
100
-
101
- // Send the action to the Actor and return the response status
102
- async fn act ( actor : & Actor , action : Action ) -> Result < Status , String > {
103
- // Check if the system is paused
104
- if actor. is_paused ( ) {
105
- return Err ( "System is paused" . to_string ( ) ) ;
106
- }
107
-
108
- // Return early if the request is already succeeded
109
- if let Ok ( Some ( status) ) = actor. pool_get_status ( & action. request_key ( ) ) {
110
- if matches ! ( status. status( ) , Status :: Success { .. } ) {
111
- return Ok ( status. into_status ( ) ) ;
112
- }
113
- }
114
-
115
- // Just logging the status of the request
116
- let _ = actor
117
- . pool_get_status ( & action. request_key ( ) )
118
- . map ( |status_opt| {
119
- tracing:: trace!(
120
- "trace request in {request_key}: {status}" ,
121
- request_key = action. request_key( ) ,
122
- status = status_opt
123
- . map( |status| status. into_status( ) . to_string( ) )
124
- . unwrap_or( "None" . to_string( ) ) ,
125
- )
126
- } ) ;
127
-
128
- // Send the action to the Actor and return the response status
129
- actor. act ( action. clone ( ) ) . await . map ( |status| {
130
- tracing:: trace!(
131
- "trace request out {request_key}: {status}" ,
132
- request_key = action. request_key( ) ,
133
- status = status. status( )
134
- ) ;
135
- status. into_status ( )
136
- } )
137
- }
0 commit comments