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: align implicit default ttl with specs #749

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/ipns/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,10 @@ const log = logger('helia:ipns')
const MINUTE = 60 * 1000
const HOUR = 60 * MINUTE

const DEFAULT_LIFETIME_MS = 24 * HOUR
const DEFAULT_LIFETIME_MS = 48 * HOUR
const DEFAULT_REPUBLISH_INTERVAL_MS = 23 * HOUR

const DEFAULT_TTL_NS = BigInt(HOUR) * 1_000_000n
const DEFAULT_TTL_NS = BigInt(MINUTE) * 5_000_000n // 5 minutes

export type PublishProgressEvents =
ProgressEvent<'ipns:publish:start'> |
Expand All @@ -311,7 +311,7 @@ export type ResolveDNSLinkProgressEvents =

export interface PublishOptions extends AbortOptions, ProgressOptions<PublishProgressEvents | IPNSRoutingEvents> {
/**
* Time duration of the record in ms (default: 24hrs)
* Time duration of the signature validity in ms (default: 48hrs)
*/
lifetime?: number

Expand All @@ -327,7 +327,7 @@ export interface PublishOptions extends AbortOptions, ProgressOptions<PublishPro
v1Compatible?: boolean

/**
* The TTL of the record in ms (default: 1 hour)
* The TTL of the record in ms (default: 5 minutes)
Copy link
Member

@achingbrain achingbrain Feb 27, 2025

Choose a reason for hiding this comment

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

Maybe I'm missing something but the suggested default is one hour?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Aha! Like it says in the issue description..

*/
ttl?: number
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ipns/test/publish.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('publish', () => {
const ipnsEntry = await name.publish(key, cid)

expect(ipnsEntry).to.have.property('sequence', 1n)
expect(ipnsEntry).to.have.property('ttl', 3_600_000_000_000n) // 1 hour
expect(ipnsEntry).to.have.property('ttl', 300_000_000_000n) // 5 minutes
})

it('should publish an IPNS record with a custom lifetime params', async function () {
Expand Down