77use std:: str:: FromStr ;
88
99use crate :: server:: {
10- app_data:: AppData ,
11- models:: {
12- GetRoundRequest , IsSlotEmptyRequest , IsSlotEmptyResponse , PreviousCiphertextRequest ,
13- PreviousCiphertextResponse , WebhookPayload ,
14- } ,
15- CONFIG ,
10+ CONFIG , app_data:: AppData , models:: {
11+ GetRoundRequest , IsSlotEmptyRequest , IsSlotEmptyResponse , PreviousCiphertextRequest , PreviousCiphertextResponse , RoundRequestWithRequester , WebhookPayload
12+ }
1613} ;
1714use actix_web:: { web, HttpResponse , Responder } ;
18- use alloy:: primitives:: { Address , Bytes , U256 } ;
15+ use alloy:: { primitives:: { Address , Bytes , U256 } } ;
1916use e3_sdk:: evm_helpers:: contracts:: {
2017 EnclaveContract , EnclaveContractFactory , EnclaveWrite , ReadWrite ,
2118} ;
@@ -26,7 +23,7 @@ pub fn setup_routes(config: &mut web::ServiceConfig) {
2623 config. service (
2724 web:: scope ( "/state" )
2825 . route ( "/result" , web:: post ( ) . to ( get_round_result) )
29- . route ( "/all" , web:: get ( ) . to ( get_all_round_results) )
26+ . route ( "/all" , web:: post ( ) . to ( get_all_round_results) )
3027 . route ( "/lite" , web:: post ( ) . to ( get_round_state_lite) )
3128 // Do we need protection on this endpoint? technically they would need to send a valid proof for it to
3229 // be included on chain
@@ -222,7 +219,9 @@ async fn get_round_result(
222219/// # Returns
223220///
224221/// * A JSON response containing the results for all rounds
225- async fn get_all_round_results ( store : web:: Data < AppData > ) -> impl Responder {
222+ async fn get_all_round_results ( data : web:: Json :: < RoundRequestWithRequester > , store: web:: Data < AppData > ) -> impl Responder {
223+ let incoming = data. into_inner ( ) ;
224+
226225 let round_count = match store. current_round ( ) . get_current_round_id ( ) . await {
227226 Ok ( count) => count,
228227 Err ( e) => {
@@ -232,11 +231,21 @@ async fn get_all_round_results(store: web::Data<AppData>) -> impl Responder {
232231 } ;
233232
234233 let mut states = Vec :: new ( ) ;
234+ let requesters = incoming. requesters ;
235235
236236 // FIXME: This assumes ids are ordered
237237 for i in 0 ..round_count + 1 {
238238 match store. e3 ( i) . get_web_result_request ( ) . await {
239- Ok ( w) => states. push ( w) ,
239+ Ok ( w) => {
240+ if !requesters. is_empty ( ) {
241+ // if we have any requesters to filter by, do it
242+ if requesters. contains ( & w. requester ) {
243+ states. push ( w) ;
244+ }
245+ } else {
246+ states. push ( w) ;
247+ }
248+ }
240249 Err ( e) => {
241250 info ! ( "Error retrieving state for round {}: {:?}" , i, e) ;
242251 continue ;
0 commit comments