44use crate :: escrow_accounts:: EscrowAccounts ;
55use alloy:: dyn_abi:: Eip712Domain ;
66use alloy:: primitives:: Address ;
7- use eventuals:: Eventual ;
87use sqlx:: postgres:: PgListener ;
98use sqlx:: PgPool ;
109use std:: collections:: HashSet ;
@@ -16,10 +15,11 @@ use tap_core::receipt::{
1615 state:: Checking ,
1716 ReceiptWithState ,
1817} ;
18+ use tokio:: sync:: watch:: Receiver ;
1919use tracing:: error;
2020
2121pub struct DenyListCheck {
22- escrow_accounts : Eventual < EscrowAccounts > ,
22+ escrow_accounts : Receiver < EscrowAccounts > ,
2323 domain_separator : Eip712Domain ,
2424 sender_denylist : Arc < RwLock < HashSet < Address > > > ,
2525 _sender_denylist_watcher_handle : Arc < tokio:: task:: JoinHandle < ( ) > > ,
@@ -29,7 +29,7 @@ pub struct DenyListCheck {
2929impl DenyListCheck {
3030 pub async fn new (
3131 pgpool : PgPool ,
32- escrow_accounts : Eventual < EscrowAccounts > ,
32+ escrow_accounts : Receiver < EscrowAccounts > ,
3333 domain_separator : Eip712Domain ,
3434 ) -> Self {
3535 // Listen to pg_notify events. We start it before updating the sender_denylist so that we
@@ -163,7 +163,7 @@ impl Check for DenyListCheck {
163163 anyhow:: anyhow!( e)
164164 } )
165165 . map_err ( CheckError :: Failed ) ?;
166- let escrow_accounts_snapshot = self . escrow_accounts . value_immediate ( ) . unwrap_or_default ( ) ;
166+ let escrow_accounts_snapshot = self . escrow_accounts . borrow ( ) ;
167167
168168 let receipt_sender = escrow_accounts_snapshot
169169 . get_sender_for_signer ( & receipt_signer)
@@ -200,6 +200,7 @@ mod tests {
200200
201201 use alloy:: hex:: ToHexExt ;
202202 use tap_core:: receipt:: { Context , ReceiptWithState } ;
203+ use tokio:: sync:: watch;
203204
204205 use crate :: test_vectors:: { self , create_signed_receipt, TAP_SENDER } ;
205206
@@ -209,14 +210,15 @@ mod tests {
209210
210211 async fn new_deny_list_check ( pgpool : PgPool ) -> DenyListCheck {
211212 // Mock escrow accounts
212- let escrow_accounts = Eventual :: from_value ( EscrowAccounts :: new (
213+ let escrow_accounts_rx = watch :: channel ( EscrowAccounts :: new (
213214 test_vectors:: ESCROW_ACCOUNTS_BALANCES . to_owned ( ) ,
214215 test_vectors:: ESCROW_ACCOUNTS_SENDERS_TO_SIGNERS . to_owned ( ) ,
215- ) ) ;
216+ ) )
217+ . 1 ;
216218
217219 DenyListCheck :: new (
218220 pgpool,
219- escrow_accounts ,
221+ escrow_accounts_rx ,
220222 test_vectors:: TAP_EIP712_DOMAIN . to_owned ( ) ,
221223 )
222224 . await
0 commit comments