Skip to content

Commit 6d25ea3

Browse files
taslimmuhammedgusinacio
authored andcommitted
Fn(Ref<'_,T>)->Fut
1 parent c42f1d8 commit 6d25ea3

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

common/src/watcher.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::{future::Future, time::Duration};
1010

1111
use tokio::{
1212
select,
13-
sync::watch,
13+
sync::watch::{self, Ref},
1414
task::JoinHandle,
1515
time::{self, sleep},
1616
};
@@ -91,18 +91,18 @@ where
9191
pub fn watch_pipe<T, F, Fut>(rx: watch::Receiver<T>, function: F) -> JoinHandle<()>
9292
where
9393
T: Clone + Send + Sync + 'static,
94-
F: Fn(T) -> Fut + Send + Sync + 'static,
94+
F: Fn(Ref<'_, T>) -> Fut + Send + Sync + 'static,
9595
Fut: Future<Output = ()> + Send + 'static,
9696
{
9797
tokio::spawn(async move {
9898
let mut rx = rx;
99-
let value = rx.borrow().clone();
99+
let value = rx.borrow();
100100
function(value).await;
101101
loop {
102102
let res = rx.changed().await;
103103
match res {
104104
Ok(_) => {
105-
let value = rx.borrow().clone();
105+
let value = rx.borrow();
106106
function(value).await;
107107
}
108108
Err(err) => {

tap-agent/src/agent/sender_account.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ impl Actor for SenderAccount {
499499
let myself_clone = myself.clone();
500500
let _indexer_allocations_handle = watch_pipe(indexer_allocations, move |allocation_ids| {
501501
let myself = myself_clone.clone();
502+
let allocation_ids = allocation_ids.clone();
502503
async move {
503504
// Update the allocation_ids
504505
myself
@@ -515,6 +516,7 @@ impl Actor for SenderAccount {
515516
let _escrow_account_monitor = watch_pipe(accounts_clone, move |escrow_account| {
516517
let myself = myself_clone.clone();
517518
let pgpool = pgpool_clone.clone();
519+
let escrow_account = escrow_account.clone();
518520
async move {
519521
// Get balance or default value for sender
520522
// this balance already takes into account thawing

0 commit comments

Comments
 (0)