@@ -18,13 +18,13 @@ use async_trait::async_trait;
1818use crate :: {
1919 manager:: adapters:: * ,
2020 rav:: SignedRAV ,
21- receipt:: { checks:: StatefulTimestampCheck , state:: Checking , ReceiptWithState } ,
21+ receipt:: { checks:: StatefulTimestampCheck , state:: Checking , ReceiptWithState , SignedReceipt } ,
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 , SignedReceipt > > > > ;
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 , SignedReceipt > , 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 , SignedReceipt > ) > , 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 , SignedReceipt > > , InMemoryError > {
103103 self . retrieve_receipts_in_timestamp_range ( ..=timestamp_ns, None )
104104 . await
105105 }
@@ -147,12 +147,12 @@ impl RAVRead for InMemoryContext {
147147}
148148
149149#[ async_trait]
150- impl ReceiptStore for InMemoryContext {
150+ impl ReceiptStore < SignedReceipt > for InMemoryContext {
151151 type AdapterError = InMemoryError ;
152152
153153 async fn store_receipt (
154154 & self ,
155- receipt : ReceiptWithState < Checking > ,
155+ receipt : ReceiptWithState < Checking , SignedReceipt > ,
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 < SignedReceipt > 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 , SignedReceipt > > , 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 , SignedReceipt > > = receipt_storage
191191 . iter ( )
192192 . filter ( |( _, rx_receipt) | {
193193 timestamp_range_ns. contains ( & rx_receipt. signed_receipt ( ) . message . timestamp_ns )
@@ -264,7 +264,7 @@ pub mod checks {
264264 receipt:: {
265265 checks:: { Check , CheckError , CheckResult , ReceiptCheck } ,
266266 state:: Checking ,
267- Context , ReceiptError , ReceiptWithState ,
267+ Context , ReceiptError , ReceiptWithState , SignedReceipt ,
268268 } ,
269269 signed_message:: MessageId ,
270270 } ;
@@ -274,7 +274,7 @@ pub mod checks {
274274 valid_signers : HashSet < Address > ,
275275 allocation_ids : Arc < RwLock < HashSet < Address > > > ,
276276 _query_appraisals : Arc < RwLock < HashMap < MessageId , u128 > > > ,
277- ) -> Vec < ReceiptCheck > {
277+ ) -> Vec < ReceiptCheck < SignedReceipt > > {
278278 vec ! [
279279 // Arc::new(UniqueCheck ),
280280 // Arc::new(ValueCheck { query_appraisals }),
@@ -291,8 +291,12 @@ pub mod checks {
291291 }
292292
293293 #[ async_trait:: async_trait]
294- impl Check for AllocationIdCheck {
295- async fn check ( & self , _: & Context , receipt : & ReceiptWithState < Checking > ) -> CheckResult {
294+ impl Check < SignedReceipt > for AllocationIdCheck {
295+ async fn check (
296+ & self ,
297+ _: & Context ,
298+ receipt : & ReceiptWithState < Checking , SignedReceipt > ,
299+ ) -> CheckResult {
296300 let received_allocation_id = receipt. signed_receipt ( ) . message . allocation_id ;
297301 if self
298302 . allocation_ids
@@ -318,8 +322,12 @@ pub mod checks {
318322 }
319323
320324 #[ async_trait:: async_trait]
321- impl Check for SignatureCheck {
322- async fn check ( & self , _: & Context , receipt : & ReceiptWithState < Checking > ) -> CheckResult {
325+ impl Check < SignedReceipt > for SignatureCheck {
326+ async fn check (
327+ & self ,
328+ _: & Context ,
329+ receipt : & ReceiptWithState < Checking , SignedReceipt > ,
330+ ) -> CheckResult {
323331 let recovered_address = receipt
324332 . signed_receipt ( )
325333 . recover_signer ( & self . domain_separator )
0 commit comments