@@ -226,8 +226,6 @@ impl ReceiptRead<TapReceipt> for TapAgentContext<Horizon> {
226226 error : format ! ( "{:?}." , e) ,
227227 } ) ?;
228228
229- // TODO filter by data_service when we have multiple data services
230-
231229 let records = sqlx:: query!(
232230 r#"
233231 SELECT
@@ -244,15 +242,17 @@ impl ReceiptRead<TapReceipt> for TapAgentContext<Horizon> {
244242 WHERE
245243 collection_id = $1
246244 AND payer = $2
247- AND service_provider = $3
248- AND signer_address IN (SELECT unnest($4::text[]))
249- AND $5::numrange @> timestamp_ns
245+ AND data_service = $3
246+ AND service_provider = $4
247+ AND signer_address IN (SELECT unnest($5::text[]))
248+ AND $6::numrange @> timestamp_ns
250249 ORDER BY timestamp_ns ASC
251- LIMIT $6
250+ LIMIT $7
252251 "# ,
253252 CollectionId :: from( self . allocation_id) . encode_hex( ) ,
254253 self . sender. encode_hex( ) ,
255254 self . indexer_address. encode_hex( ) ,
255+ self . indexer_address. encode_hex( ) ,
256256 & signers,
257257 rangebounds_to_pgrange( timestamp_range_ns) ,
258258 ( receipts_limit + 1 ) as i64 ,
@@ -371,13 +371,15 @@ impl ReceiptDelete for TapAgentContext<Horizon> {
371371 AND signer_address IN (SELECT unnest($2::text[]))
372372 AND $3::numrange @> timestamp_ns
373373 AND payer = $4
374- AND service_provider = $5
374+ AND data_service = $5
375+ AND service_provider = $6
375376 "# ,
376377 CollectionId :: from( self . allocation_id) . encode_hex( ) ,
377378 & signers,
378379 rangebounds_to_pgrange( timestamp_ns) ,
379380 self . sender. encode_hex( ) ,
380381 self . indexer_address. encode_hex( ) ,
382+ self . indexer_address. encode_hex( ) ,
381383 )
382384 . execute ( & self . pgpool )
383385 . await ?;
0 commit comments