Skip to content

Commit

Permalink
Merge pull request #30 from xash/skip_same_entries
Browse files Browse the repository at this point in the history
Don't insert entries that are equally "new" to stored ones
  • Loading branch information
sgwilym authored Nov 13, 2024
2 parents f2a4e8f + f123bbf commit 827329f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,25 @@ export class Store<
};
}

const otherPayloadLengthIsGreater =
entry.payloadLength < otherEntry.payloadLength;

// If the timestamps and hashes are the same, and the other payload's length is greater, we have a no-op.
if (
otherEntry.timestamp === entry.timestamp &&
payloadDigestOrder === 0 && otherPayloadLengthIsGreater
payloadDigestOrder === 0 &&
entry.payloadLength < otherEntry.payloadLength
) {
this.ingestionMutex.release(acquisitionId);

return {
kind: "no_op",
reason: "obsolete_from_same_subspace",
};
}

// If all three qualities are the same, neither is newer than the other. So we can also have a no-op.
if (
otherEntry.timestamp === entry.timestamp &&
payloadDigestOrder === 0 &&
entry.payloadLength === otherEntry.payloadLength
) {
this.ingestionMutex.release(acquisitionId);

Expand Down

0 comments on commit 827329f

Please sign in to comment.