Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: respect the IPNS TTL field #482

Merged
merged 2 commits into from
Apr 3, 2024
Merged

fix: respect the IPNS TTL field #482

merged 2 commits into from
Apr 3, 2024

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Apr 3, 2024

Uses the @libp2p/record timeReceived property and the .ttl field of the IPNS Record to calcuate the TTL of the record separately from the record EOL.

This was going to be a push to #473 but it was merged prematurely.

Fixes #479

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

Uses the `@libp2p/record` `timeReceived` property and the `.ttl` field
of the IPNS Record to calcuate the TTL of the record separately from
the record EOL.

This was going to be a push to #473 but it was merged prematurely.
@achingbrain achingbrain requested a review from a team as a code owner April 3, 2024 07:42
@achingbrain achingbrain changed the title fix: honor IPNS TTL field fix: respect the IPNS TTL field Apr 3, 2024
@SgtPooki SgtPooki self-requested a review April 3, 2024 17:07
Copy link
Member

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, a few minor comments

packages/ipns/test/publish.spec.ts Outdated Show resolved Hide resolved
packages/ipns/test/publish.spec.ts Outdated Show resolved Hide resolved
// add the local record to our list of resolved record, and also
// search the routing for updates - the most up to date record will be
// returned
records.push(record)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we are calling ipnsValidator twice for these records. it would be nice to consolidate the record processing logic

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, there's no point in re-validating the cached record, but it takes several orders of magnitude longer to look up a record than it does to validate it so any performance gain would be unnoticeable.

Co-authored-by: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com>
@achingbrain achingbrain merged commit 1561e4a into main Apr 3, 2024
18 checks passed
@achingbrain achingbrain deleted the fix/honor-ipns-ttl branch April 3, 2024 18:24
@achingbrain achingbrain mentioned this pull request Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: ipns doesn't purge cache based on TTL
2 participants