@@ -17,14 +17,14 @@ use async_trait::async_trait;
1717
1818use crate :: {
1919 manager:: adapters:: * ,
20- rav:: SignedRAV ,
21- receipt:: { checks:: StatefulTimestampCheck , state:: Checking , ReceiptWithState } ,
20+ rav:: { ReceiptAggregateVoucher , SignedRAV } ,
21+ receipt:: { checks:: StatefulTimestampCheck , state:: Checking , Receipt , ReceiptWithState } ,
2222 signed_message:: MessageId ,
2323} ;
2424
2525pub type EscrowStorage = Arc < RwLock < HashMap < Address , u128 > > > ;
2626pub type QueryAppraisals = Arc < RwLock < HashMap < MessageId , u128 > > > ;
27- pub type ReceiptStorage = Arc < RwLock < HashMap < u64 , ReceiptWithState < Checking > > > > ;
27+ pub type ReceiptStorage = Arc < RwLock < HashMap < u64 , ReceiptWithState < Checking , Receipt > > > > ;
2828pub type RAVStorage = Arc < RwLock < Option < SignedRAV > > > ;
2929
3030use thiserror:: Error ;
@@ -71,7 +71,7 @@ impl InMemoryContext {
7171 pub async fn retrieve_receipt_by_id (
7272 & self ,
7373 receipt_id : u64 ,
74- ) -> Result < ReceiptWithState < Checking > , InMemoryError > {
74+ ) -> Result < ReceiptWithState < Checking , Receipt > , InMemoryError > {
7575 let receipt_storage = self . receipt_storage . read ( ) . unwrap ( ) ;
7676
7777 receipt_storage
@@ -85,7 +85,7 @@ impl InMemoryContext {
8585 pub async fn retrieve_receipts_by_timestamp (
8686 & self ,
8787 timestamp_ns : u64 ,
88- ) -> Result < Vec < ( u64 , ReceiptWithState < Checking > ) > , InMemoryError > {
88+ ) -> Result < Vec < ( u64 , ReceiptWithState < Checking , Receipt > ) > , InMemoryError > {
8989 let receipt_storage = self . receipt_storage . read ( ) . unwrap ( ) ;
9090 Ok ( receipt_storage
9191 . iter ( )
@@ -99,7 +99,7 @@ impl InMemoryContext {
9999 pub async fn retrieve_receipts_upto_timestamp (
100100 & self ,
101101 timestamp_ns : u64 ,
102- ) -> Result < Vec < ReceiptWithState < Checking > > , InMemoryError > {
102+ ) -> Result < Vec < ReceiptWithState < Checking , Receipt > > , InMemoryError > {
103103 self . retrieve_receipts_in_timestamp_range ( ..=timestamp_ns, None )
104104 . await
105105 }
@@ -125,7 +125,7 @@ impl InMemoryContext {
125125}
126126
127127#[ async_trait]
128- impl RAVStore for InMemoryContext {
128+ impl RAVStore < ReceiptAggregateVoucher > for InMemoryContext {
129129 type AdapterError = InMemoryError ;
130130
131131 async fn update_last_rav ( & self , rav : SignedRAV ) -> Result < ( ) , Self :: AdapterError > {
@@ -138,7 +138,7 @@ impl RAVStore for InMemoryContext {
138138}
139139
140140#[ async_trait]
141- impl RAVRead for InMemoryContext {
141+ impl RAVRead < ReceiptAggregateVoucher > for InMemoryContext {
142142 type AdapterError = InMemoryError ;
143143
144144 async fn last_rav ( & self ) -> Result < Option < SignedRAV > , Self :: AdapterError > {
@@ -147,12 +147,12 @@ impl RAVRead for InMemoryContext {
147147}
148148
149149#[ async_trait]
150- impl ReceiptStore for InMemoryContext {
150+ impl ReceiptStore < Receipt > for InMemoryContext {
151151 type AdapterError = InMemoryError ;
152152
153153 async fn store_receipt (
154154 & self ,
155- receipt : ReceiptWithState < Checking > ,
155+ receipt : ReceiptWithState < Checking , Receipt > ,
156156 ) -> Result < u64 , Self :: AdapterError > {
157157 let mut id_pointer = self . unique_id . write ( ) . unwrap ( ) ;
158158 let id_previous = * id_pointer;
@@ -179,15 +179,15 @@ impl ReceiptDelete for InMemoryContext {
179179 }
180180}
181181#[ async_trait]
182- impl ReceiptRead for InMemoryContext {
182+ impl ReceiptRead < Receipt > for InMemoryContext {
183183 type AdapterError = InMemoryError ;
184184 async fn retrieve_receipts_in_timestamp_range < R : RangeBounds < u64 > + std:: marker:: Send > (
185185 & self ,
186186 timestamp_range_ns : R ,
187187 limit : Option < u64 > ,
188- ) -> Result < Vec < ReceiptWithState < Checking > > , Self :: AdapterError > {
188+ ) -> Result < Vec < ReceiptWithState < Checking , Receipt > > , Self :: AdapterError > {
189189 let receipt_storage = self . receipt_storage . read ( ) . unwrap ( ) ;
190- let mut receipts_in_range: Vec < ReceiptWithState < Checking > > = receipt_storage
190+ let mut receipts_in_range: Vec < ReceiptWithState < Checking , Receipt > > = receipt_storage
191191 . iter ( )
192192 . filter ( |( _, rx_receipt) | {
193193 timestamp_range_ns. contains ( & rx_receipt. signed_receipt ( ) . message . timestamp_ns )
@@ -274,7 +274,7 @@ pub mod checks {
274274 receipt:: {
275275 checks:: { Check , CheckError , CheckResult , ReceiptCheck } ,
276276 state:: Checking ,
277- Context , ReceiptError , ReceiptWithState ,
277+ Context , Receipt , ReceiptError , ReceiptWithState ,
278278 } ,
279279 signed_message:: MessageId ,
280280 } ;
@@ -284,7 +284,7 @@ pub mod checks {
284284 valid_signers : HashSet < Address > ,
285285 allocation_ids : Arc < RwLock < HashSet < Address > > > ,
286286 _query_appraisals : Arc < RwLock < HashMap < MessageId , u128 > > > ,
287- ) -> Vec < ReceiptCheck > {
287+ ) -> Vec < ReceiptCheck < Receipt > > {
288288 vec ! [
289289 // Arc::new(UniqueCheck ),
290290 // Arc::new(ValueCheck { query_appraisals }),
@@ -301,8 +301,12 @@ pub mod checks {
301301 }
302302
303303 #[ async_trait:: async_trait]
304- impl Check for AllocationIdCheck {
305- async fn check ( & self , _: & Context , receipt : & ReceiptWithState < Checking > ) -> CheckResult {
304+ impl Check < Receipt > for AllocationIdCheck {
305+ async fn check (
306+ & self ,
307+ _: & Context ,
308+ receipt : & ReceiptWithState < Checking , Receipt > ,
309+ ) -> CheckResult {
306310 let received_allocation_id = receipt. signed_receipt ( ) . message . allocation_id ;
307311 if self
308312 . allocation_ids
@@ -328,8 +332,12 @@ pub mod checks {
328332 }
329333
330334 #[ async_trait:: async_trait]
331- impl Check for SignatureCheck {
332- async fn check ( & self , _: & Context , receipt : & ReceiptWithState < Checking > ) -> CheckResult {
335+ impl Check < Receipt > for SignatureCheck {
336+ async fn check (
337+ & self ,
338+ _: & Context ,
339+ receipt : & ReceiptWithState < Checking , Receipt > ,
340+ ) -> CheckResult {
333341 let recovered_address = receipt
334342 . signed_receipt ( )
335343 . recover_signer ( & self . domain_separator )
0 commit comments