Skip to content

Commit

Permalink
Don't verify duplicate events (very little benefit, they never save a…
Browse files Browse the repository at this point in the history
…nyways)
  • Loading branch information
mikedilger committed Sep 29, 2023
1 parent 2dbb952 commit d01a921
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ pub async fn process_new_event(
// Bump count
GLOBALS.events_processed.fetch_add(1, Ordering::SeqCst);

// Verify the event, even if a duplicate (ID could be forged)
if verify {
// Detect if duplicate. We still need to process some things even if a duplicate
let duplicate = GLOBALS.storage.has_event(event.id)?;

// Verify the event,
// Don't verify if it is a duplicate:
// NOTE: relays could send forged events with valid IDs of other events, but if
// they do that in an event that is a duplicate of one we already have, this
// duplicate will only affect seen-on information, it will not be saved.
if !duplicate && verify {
let mut maxtime = now;
maxtime.0 += GLOBALS.storage.read_setting_future_allowance_secs() as i64;
if let Err(e) = event.verify(Some(maxtime)) {
Expand All @@ -34,9 +41,6 @@ pub async fn process_new_event(
}
}

// Detect if duplicate. We still need to process some things even if a duplicate
let duplicate = GLOBALS.storage.has_event(event.id)?;

if let Some(url) = &seen_on {
// Save seen-on-relay information
GLOBALS
Expand Down

0 comments on commit d01a921

Please sign in to comment.