Skip to content

Commit

Permalink
Discard older gift wrap events (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
grunch authored Oct 11, 2024
1 parent 9e51caf commit abd4d0f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ pub async fn run(
};

let event = unwrap_gift_wrap(&my_keys, &event)?;
// Here we discard messages older than the real since parameter
let since_time = chrono::Utc::now()
.checked_sub_signed(chrono::Duration::minutes(10))
.unwrap()
.timestamp() as u64;
if event.rumor.created_at.as_u64() < since_time {
continue;
}

let message = Message::from_json(&event.rumor.content);
match message {
Expand Down
2 changes: 0 additions & 2 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ pub async fn publish_order(
let reputation = get_user_reputation(initiator_pubkey, keys).await?;
// We transform the order fields to tags to use in the event
let tags = order_to_tags(&new_order_db, reputation);

info!("order tags to be published: {:#?}", tags);
// nip33 kind with order fields as tags and order id as identifier
let event = new_event(keys, "", order_id.to_string(), tags)?;
info!("Order event to be published: {event:#?}");
Expand Down

0 comments on commit abd4d0f

Please sign in to comment.