From 07ea37e99f898df54fa5edc114c8495fd6374ea7 Mon Sep 17 00:00:00 2001 From: Guillaume Michel Date: Fri, 9 Jan 2026 21:17:37 +0100 Subject: [PATCH] fix(provider): wait for fullrt crawl completion before providing (#11137) Co-authored-by: Marcin Rataj --- core/node/provider.go | 21 ++++++++++++++++++++- docs/changelogs/v0.40.md | 6 ++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/core/node/provider.go b/core/node/provider.go index 2e385927f..57d70feb6 100644 --- a/core/node/provider.go +++ b/core/node/provider.go @@ -322,6 +322,25 @@ type dhtImpl interface { Host() host.Host MessageSender() dht_pb.MessageSender } + +type fullrtRouter struct { + *fullrt.FullRT +} + +// GetClosestPeers overrides fullrt.FullRT's GetClosestPeers and returns an +// error if the fullrt's initial network crawl isn't complete yet. +func (fr *fullrtRouter) GetClosestPeers(ctx context.Context, key string) ([]peer.ID, error) { + if !fr.Ready() { + return nil, errors.New("fullrt: initial network crawl still running") + } + return fr.FullRT.GetClosestPeers(ctx, key) +} + +var ( + _ dhtImpl = &dht.IpfsDHT{} + _ dhtImpl = &fullrtRouter{} +) + type addrsFilter interface { FilteredAddrs() []ma.Multiaddr } @@ -400,7 +419,7 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option { } case *fullrt.FullRT: if inDht != nil { - impl = inDht + impl = &fullrtRouter{inDht} } } if impl == nil { diff --git a/docs/changelogs/v0.40.md b/docs/changelogs/v0.40.md index 26914aaab..8b92baf34 100644 --- a/docs/changelogs/v0.40.md +++ b/docs/changelogs/v0.40.md @@ -15,6 +15,7 @@ This release was brought to you by the [Shipyard](https://ipshipyard.com/) team. - [๐Ÿš‡ Improved `ipfs p2p` tunnels with foreground mode](#-improved-ipfs-p2p-tunnels-with-foreground-mode) - [Improved `ipfs dag stat` output](#improved-ipfs-dag-stat-output) - [Skip bad keys when listing](#skip_bad_keys_when_listing) + - [Accelerated DHT Client and Provide Sweep now work together](#accelerated-dht-client-and-provide-sweep-now-work-together) - [๐Ÿ“ฆ๏ธ Dependency updates](#-dependency-updates) - [๐Ÿ“ Changelog](#-changelog) - [๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Contributors](#-contributors) @@ -32,6 +33,7 @@ The [Routing V1 HTTP API](https://specs.ipfs.tech/routing/http-routing-v1/) is n Adds total size progress tracking of pinned nodes during `ipfs pin add --progress`. The output now shows the total size of the pinned dag. Example output: + ``` Fetched/Processed 336 nodes (83 MB) ``` @@ -81,6 +83,10 @@ Use `--progress=true` to force progress even when piped, or `--progress=false` t Change the `ipfs key list` behavior to log an error and continue listing keys when a key cannot be read from the keystore or decoded. +#### Accelerated DHT Client and Provide Sweep now work together + +Previously, provide operations could start before the Accelerated DHT Client discovered enough peers, causing sweep mode to lose its efficiency benefits. Now, providing waits for the initial network crawl (about 10 minutes). Your content will be properly distributed across DHT regions after initial DHT map is created. Check `ipfs provide stat` to see when providing begins. + #### ๐Ÿ“ฆ๏ธ Dependency updates - update `go-libp2p` to [v0.46.0](https://github.com/libp2p/go-libp2p/releases/tag/v0.46.0)