File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed
aggregation_mode/batcher/src Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -79,16 +79,16 @@ impl Db {
7979 . await
8080 }
8181
82- pub async fn get_tasks_by_address (
82+ pub async fn get_tasks_by_address_with_limit (
8383 & self ,
8484 address : & str ,
8585 limit : i64 ,
8686 ) -> Result < Vec < Receipt > , sqlx:: Error > {
8787 sqlx:: query_as :: < _ , Receipt > (
8888 "SELECT status,merkle_path,nonce,address FROM tasks
8989 WHERE address = $1
90- LIMIT $2
91- ORDER BY nonce DESC " ,
90+ ORDER BY nonce DESC
91+ LIMIT $2 " ,
9292 )
9393 . bind ( address. to_lowercase ( ) )
9494 . bind ( limit)
Original file line number Diff line number Diff line change @@ -206,6 +206,8 @@ impl BatcherServer {
206206 . json ( AppResponse :: new_unsucessfull ( "Invalid address" , 400 ) ) ;
207207 }
208208
209+ let limit = params. limit . unwrap_or ( 100 ) ; // We take 100 as the default limit value
210+
209211 let address = params. address . to_lowercase ( ) ;
210212
211213 let query = if let Some ( nonce) = params. nonce {
@@ -214,7 +216,10 @@ impl BatcherServer {
214216 . get_tasks_by_address_and_nonce ( & address, nonce)
215217 . await
216218 } else {
217- state. db . get_tasks_by_address ( & address, 100 ) . await
219+ state
220+ . db
221+ . get_tasks_by_address_with_limit ( & address, limit)
222+ . await
218223 } ;
219224
220225 let Ok ( receipts) = query else {
Original file line number Diff line number Diff line change @@ -28,11 +28,14 @@ impl AppResponse {
2828 }
2929}
3030
31- /// Query parameters accepted by `GET /proof/merkle`, containing an optional proof id.
31+ /// Query parameters accepted by `GET /proof/merkle`. Requires an address, and accepts a nonce
32+ /// and a limit for the amount of tasks included in the query (the maximum value is 100).
33+ /// Note: The limit value will only be taken into account if nonce is None.
3234#[ derive( Deserialize , Clone ) ]
3335pub ( super ) struct GetReceiptsQueryParams {
3436 pub address : String ,
3537 pub nonce : Option < i64 > ,
38+ pub limit : Option < i64 > ,
3639}
3740
3841#[ derive( Serialize , Deserialize , Clone , Debug ) ]
You can’t perform that action at this time.
0 commit comments