File tree Expand file tree Collapse file tree 3 files changed +9
-15
lines changed
aggregation_mode/batcher/src Expand file tree Collapse file tree 3 files changed +9
-15
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ pub struct Config {
88 pub db_connection_url : String ,
99 pub eth_rpc_url : String ,
1010 pub payment_service_address : String ,
11- pub max_proofs_per_day : usize ,
11+ pub max_proofs_per_day : i64 ,
1212}
1313
1414impl Config {
Original file line number Diff line number Diff line change @@ -96,18 +96,15 @@ impl Db {
9696 . await
9797 }
9898
99- pub async fn get_daily_tasks_by_address (
100- & self ,
101- address : & str ,
102- ) -> Result < Vec < Receipt > , sqlx:: Error > {
103- sqlx:: query_as :: < _ , Receipt > (
104- "SELECT status,merkle_path,nonce,address
99+ pub async fn get_daily_tasks_by_address ( & self , address : & str ) -> Result < i64 , sqlx:: Error > {
100+ sqlx:: query_scalar :: < _ , i64 > (
101+ "SELECT COUNT(*)
105102 FROM tasks
106103 WHERE address = $1
107104 AND inserted_at::date = CURRENT_DATE" ,
108105 )
109106 . bind ( address. to_lowercase ( ) )
110- . fetch_all ( & self . pool )
107+ . fetch_one ( & self . pool )
111108 . await
112109 }
113110
Original file line number Diff line number Diff line change @@ -102,16 +102,13 @@ impl BatcherServer {
102102 let state = state. get_ref ( ) ;
103103
104104 // Checking if this address has submited more proofs than the ones allowed per day
105- let daily_tasks_by_address = match state
105+ let Ok ( daily_tasks_by_address) = state
106106 . db
107107 . get_daily_tasks_by_address ( & recovered_address)
108108 . await
109- {
110- Ok ( receipts) => receipts. len ( ) ,
111- Err ( _) => {
112- return HttpResponse :: InternalServerError ( )
113- . json ( AppResponse :: new_unsucessfull ( "Internal server error" , 500 ) )
114- }
109+ else {
110+ return HttpResponse :: InternalServerError ( )
111+ . json ( AppResponse :: new_unsucessfull ( "Internal server error" , 500 ) ) ;
115112 } ;
116113
117114 if daily_tasks_by_address >= state. config . max_proofs_per_day {
You can’t perform that action at this time.
0 commit comments