4
4
use crate :: escrow_accounts:: EscrowAccounts ;
5
5
use alloy:: dyn_abi:: Eip712Domain ;
6
6
use alloy:: primitives:: Address ;
7
- use eventuals:: Eventual ;
8
7
use sqlx:: postgres:: PgListener ;
9
8
use sqlx:: PgPool ;
10
9
use std:: collections:: HashSet ;
@@ -16,10 +15,11 @@ use tap_core::receipt::{
16
15
state:: Checking ,
17
16
ReceiptWithState ,
18
17
} ;
18
+ use tokio:: sync:: watch:: Receiver ;
19
19
use tracing:: error;
20
20
21
21
pub struct DenyListCheck {
22
- escrow_accounts : Eventual < EscrowAccounts > ,
22
+ escrow_accounts : Receiver < EscrowAccounts > ,
23
23
domain_separator : Eip712Domain ,
24
24
sender_denylist : Arc < RwLock < HashSet < Address > > > ,
25
25
_sender_denylist_watcher_handle : Arc < tokio:: task:: JoinHandle < ( ) > > ,
@@ -29,7 +29,7 @@ pub struct DenyListCheck {
29
29
impl DenyListCheck {
30
30
pub async fn new (
31
31
pgpool : PgPool ,
32
- escrow_accounts : Eventual < EscrowAccounts > ,
32
+ escrow_accounts : Receiver < EscrowAccounts > ,
33
33
domain_separator : Eip712Domain ,
34
34
) -> Self {
35
35
// Listen to pg_notify events. We start it before updating the sender_denylist so that we
@@ -163,7 +163,7 @@ impl Check for DenyListCheck {
163
163
anyhow:: anyhow!( e)
164
164
} )
165
165
. 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 ( ) ;
167
167
168
168
let receipt_sender = escrow_accounts_snapshot
169
169
. get_sender_for_signer ( & receipt_signer)
@@ -200,6 +200,7 @@ mod tests {
200
200
201
201
use alloy:: hex:: ToHexExt ;
202
202
use tap_core:: receipt:: { Context , ReceiptWithState } ;
203
+ use tokio:: sync:: watch;
203
204
204
205
use crate :: test_vectors:: { self , create_signed_receipt, TAP_SENDER } ;
205
206
@@ -209,14 +210,15 @@ mod tests {
209
210
210
211
async fn new_deny_list_check ( pgpool : PgPool ) -> DenyListCheck {
211
212
// Mock escrow accounts
212
- let escrow_accounts = Eventual :: from_value ( EscrowAccounts :: new (
213
+ let escrow_accounts_rx = watch :: channel ( EscrowAccounts :: new (
213
214
test_vectors:: ESCROW_ACCOUNTS_BALANCES . to_owned ( ) ,
214
215
test_vectors:: ESCROW_ACCOUNTS_SENDERS_TO_SIGNERS . to_owned ( ) ,
215
- ) ) ;
216
+ ) )
217
+ . 1 ;
216
218
217
219
DenyListCheck :: new (
218
220
pgpool,
219
- escrow_accounts ,
221
+ escrow_accounts_rx ,
220
222
test_vectors:: TAP_EIP712_DOMAIN . to_owned ( ) ,
221
223
)
222
224
. await
0 commit comments