v0.42.0
Note
This release was brought to you by the Shipyard team.
Highlights
⚠️ Breaking changes
Constructors no longer take a context.Context (#1282)
The lifecycle context was removed from all constructors. The DHT now runs until Close() is called; cancelling a context no longer tears it down.
| Before | After |
|---|---|
dht.New(ctx, h, opts...) |
dht.New(h, opts...) |
dht.NewDHT(ctx, h, dstore) |
dht.NewDHT(h, dstore) |
dht.NewDHTClient(ctx, h, dstore) |
dht.NewDHTClient(h, dstore) |
dual.New(ctx, h, opts...) |
dual.New(h, opts...) |
records.NewProviderManager(ctx, ...) |
records.NewProviderManager(...) |
rtrefresh.NewRtRefreshManager(ctx, ...) |
rtrefresh.NewRtRefreshManager(...) |
Migration: drop the context argument. If you relied on cancelling the constructor context to shut the DHT down, call Close() instead. Close() blocks until all long-lived components have stopped. Note that in-flight RPC handlers are owned by the libp2p host, so close the host before closing any datastore handed to the DHT.
ProviderStore option removed (#1277 by @guillaumemichel)
Custom ProviderStore implementations can no longer be injected; the DHT always runs the built-in provider manager. The dht.ProviderStore(...) option is replaced by datastore-level configuration:
// Before: inject a custom provider store
d, err := dht.New(ctx, h, dht.ProviderStore(customStore))
// After: configure the built-in provider manager
d, err := dht.New(h,
dht.ProviderDatastore(dstore), // dedicated datastore for provider records
dht.ProviderManagerOpts( // tune the built-in manager
records.ProvideValidity(48*time.Hour),
records.Cache(myLRU),
),
)New options: ValueDatastore and ProviderDatastore give value and provider records their own physical datastores (both default to the datastore set with Datastore). The dht.ProviderStore() getter on IpfsDHT remains available.
Value records are stored under namespaced datastore keys (#1277)
Value records used to be stored at the datastore root as /<base32(key)>; they are now namespaced by record type: /<namespace>/<base32(key)> (e.g. /pk/..., /ipns/...). This keeps a shared datastore collision-free and enables per-namespace garbage collection.
Migration: there is no automatic key migration. On upgrade, value records persisted by earlier versions are simply not found under the new layout — nodes will re-store them as the network republishes (records expire after MaxRecordAge, 48h by default, anyway). If you persist the DHT datastore and want to reclaim space, you can delete leftover root-level base32 keys. Provider records are unaffected (already namespaced under /providers/).
What's Changed
- fix: cap closer peers accepted per response by @lidel in #1270
- fix: correct delete-error check in provider gc by @lidel in #1271
- chore(deps): bump golang.org/x/net from 0.53.0 to 0.55.0 by @dependabot[bot] in #1272
- Update dependencies by @gammazero in #1273
- chore(deps): bump golang.org/x/crypto from 0.51.0 to 0.52.0 by @dependabot[bot] in #1274
- test: fix flaky TestOptimisticProvide timeout and peerIDs seeding by @guillaumemichel in #1276
- upgrade go-test to v0.4.0 by @gammazero in #1275
- test: fix flaky TestProvidesMany by @guillaumemichel in #1278
- chore: bump go-libp2p-kbucket by @guillaumemichel in #1279
- chore: migrate from math/rand to math/rand/v2 by @guillaumemichel in #1280
- refactor(pb): bound the serialized size of a peer record by @guillaumemichel in #1281
- update dependencies by @gammazero in #1283
- refactor(records): consolidate records persistence by @guillaumemichel in #1277
- refactor: remove lifecycle context from constructors by @guillaumemichel in #1282
Full Changelog: v0.41.0...v0.42.0
