Skip to content

Commit 5677cf0

Browse files
authored
fix: align implicit default ttl with specs (1h→5m) (#336)
This PR is changing implicit default TTL of IPNS Record produced by this library from 1h to 5m. Same rationale as ipfs/kubo#10718 and ipfs/helia#749. This library has its own default TTL, which is separate from one we already updated ipfs/helia#749. Making this change so we have the same default everywhere. Historical notes - Before April 2024 the IPNS Record TTL was not set (0) in this library - Since #308 the `1h` default produced by this library started causing stale cache issues that end users often report as "ipns is slow (to update/propagate)". - We've changed default recommendation to 5m in ipfs/specs#492
1 parent de2e786 commit 5677cf0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type { CID } from 'multiformats/cid'
1111
import type { MultihashDigest } from 'multiformats/hashes/interface'
1212

1313
const log = logger('ipns')
14-
const DEFAULT_TTL_NS = 60 * 60 * 1e+9 // 1 Hour or 3600 Seconds
14+
const DEFAULT_TTL_NS = 5 * 60 * 1e+9 // 5 Minutes or 300 Seconds, as suggested by https://specs.ipfs.tech/ipns/ipns-record/#ttl-uint64
1515

1616
export const namespace = '/ipns/'
1717
export const namespaceLength = namespace.length

test/index.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('ipns', function () {
3131

3232
it('should create an ipns record (V1+V2) correctly', async () => {
3333
const sequence = 0
34-
const ttl = BigInt(60 * 60 * 1e+9)
34+
const ttl = BigInt(5 * 60 * 1e+9)
3535
const validity = 1000000
3636

3737
const record = await createIPNSRecord(privateKey, contentPath, sequence, validity)
@@ -67,7 +67,7 @@ describe('ipns', function () {
6767

6868
it('should create an ipns record (V2) correctly', async () => {
6969
const sequence = 0
70-
const ttl = BigInt(60 * 60 * 1e+9)
70+
const ttl = BigInt(5 * 60 * 1e+9)
7171
const validity = 1000000
7272

7373
const record = await createIPNSRecord(privateKey, contentPath, sequence, validity, { v1Compatible: false })

0 commit comments

Comments
 (0)