Skip to content

Commit

Permalink
fix: loop remove pending users task
Browse files Browse the repository at this point in the history
  • Loading branch information
thesimplekid committed Oct 8, 2023
1 parent 324ad42 commit edbb19f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use futures::{Stream, StreamExt};
use nostr_sdk::secp256k1::XOnlyPublicKey;
use serde::{Deserialize, Serialize};
use tokio::sync::Mutex;
use tokio::time::sleep;
use tracing::{debug, error, info, warn};
use types::{as_msat, unix_time, PendingInvoice, PendingUser, User, UserKind};
use url::Url;
Expand Down Expand Up @@ -446,11 +447,16 @@ async fn main() -> anyhow::Result<()> {
});

let remove_expired_pending_users_task = tokio::spawn(async move {
let mut pending_users = pending_users_clone.lock().await;
loop {
let mut pending_users = pending_users_clone.lock().await;

let current_time = unix_time();

let current_time = unix_time();
pending_users.retain(|_k, v| v.expire.lt(&current_time));
drop(pending_users);

pending_users.retain(|_k, v| v.expire.lt(&current_time));
sleep(Duration::from_secs(15)).await;
}
});

tokio::select! {
Expand Down

0 comments on commit edbb19f

Please sign in to comment.