Skip to content

Commit

Permalink
chore(ipns): align implicit default ttl with specs
Browse files Browse the repository at this point in the history
lowering TTL to 5m due to ipfs/specs#492
lifetime is validity of signature, and that should be fine up to 48h,
to match DHT expiration window
  • Loading branch information
lidel committed Feb 26, 2025
1 parent 45ca6bc commit 693e3b1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
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)
*/
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

0 comments on commit 693e3b1

Please sign in to comment.