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: increase providers validity to 48 hours #2801

Merged
merged 6 commits into from
Nov 16, 2024
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
14 changes: 5 additions & 9 deletions packages/kad-dht/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
// MaxRecordAge specifies the maximum time that any node will hold onto a record
// from the time its received. This does not apply to any other forms of validity that
// the record may contain.
// For example, a record may contain an ipns entry with an EOL saying its valid
// until the year 2020 (a great time in the future). For that record to stick around
// it must be rebroadcasted more frequently than once every 'MaxRecordAge'

import { KEEP_ALIVE } from '@libp2p/interface'

export const second = 1000
Expand All @@ -15,12 +8,15 @@ export const MAX_RECORD_AGE = 36 * hour

export const PROTOCOL = '/ipfs/kad/1.0.0'

export const PROVIDERS_VALIDITY = 24 * hour
/**
* @see https://github.com/libp2p/specs/blob/master/kad-dht/README.md#content-provider-advertisement-and-discovery
*/
export const PROVIDERS_VALIDITY = 48 * hour

export const PROVIDERS_CLEANUP_INTERVAL = hour

// Re-run the provide operation when the expiry of our provider records is within this amount
export const REPROVIDE_THRESHOLD = 2 * hour
export const REPROVIDE_THRESHOLD = 24 * hour

// How many reprovide operations to run at once
export const REPROVIDE_CONCURRENCY = 10
Expand Down
18 changes: 9 additions & 9 deletions packages/kad-dht/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,15 @@ export interface ProvidersInit {
*/
cacheSize?: number
/**
* How often invalid records are cleaned. (in seconds)
* How often invalid records are cleaned in seconds
*
* @default 5400
* @default 5_400
*/
cleanupInterval?: number
/**
* How long is a provider valid for. (in seconds)
* How long is a provider valid for in seconds
*
* @default 86400
* @default 86_400
*/
provideValidity?: number
}
Expand All @@ -370,28 +370,28 @@ export interface ReProvideInit {
/**
* How long to let the re-provide queue grow
*
* @default 16384
* @default 16_384
*/
maxQueueSize?: number

/**
* How long before the record expiry to re-provide in ms
*
* @default 7200000
* @default 86_400_000 (24 hours)
*/
threshold?: number

/**
* How often to check which records need reproviding in ms
* How often to check which records need re-providing in ms
*
* @default 3600000
* @default 3_600_000 (1 hour)
*/
interval?: number

/**
* How long provider records are valid for in ms
*
* @default 86400000
* @default 172_800_000 (48 hours)
*/
validity?: number
}
Expand Down
Loading