Skip to content

Commit

Permalink
feat(config): Reprovider.Strategy=flat
Browse files Browse the repository at this point in the history
Adding 'flat' strategy which works the same as the old default 'all'.
This way if anyone has memory-related regressions, they can fix without
waiting for a new release.
  • Loading branch information
lidel committed Apr 4, 2024
1 parent 44d2702 commit 9db17fb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/node/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ func OnlineProviders(useStrategicProviding bool, reprovideStrategy string, repro
keyProvider = fx.Provide(newProvidingStrategy(true, true))
case "pinned":
keyProvider = fx.Provide(newProvidingStrategy(true, false))
case "flat":
keyProvider = fx.Provide(provider.NewBlockstoreProvider)
default:
return fx.Error(fmt.Errorf("unknown reprovider strategy %q", reprovideStrategy))
}
Expand Down
2 changes: 1 addition & 1 deletion docs/changelogs/v0.28.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ To support testing scenarios where multiple Kubo instances run on the same machi

#### Pin roots are now prioritized when announcing

The pin roots are now prioritized when announcing content in the Amino DHT, making the content accessible faster.
The root CIDs of pinned content are now prioritized when announcing to the Amino DHT with [`Reprovider.Strategy`](https://github.com/ipfs/kubo/blob/master/docs/config.md#reproviderstrategy) set to `all` (default) or `pinned`, making the important CIDs accessible faster.

### 📝 Changelog

Expand Down
3 changes: 3 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,9 @@ Type: `optionalDuration` (unset for the default)
Tells reprovider what should be announced. Valid strategies are:

- `"all"` - announce all CIDs of stored blocks
- Order: root blocks of direct and recursive pins are announced first, then the rest of blockstore
- `"pinned"` - only announce pinned CIDs recursively (both roots and child blocks)
- Order: root blocks of direct and recursive pins are announced first, then the child blocks of recursive pins
- `"roots"` - only announce the root block of explicitly pinned CIDs
- **⚠️ BE CAREFUL:** node with `roots` strategy will not announce child blocks.
It makes sense only for use cases where the entire DAG is fetched in full,
Expand All @@ -1510,6 +1512,7 @@ Tells reprovider what should be announced. Valid strategies are:
providers for the missing block in the middle of a file, unless the peer
happens to already be connected to a provider and ask for child CID over
bitswap.
- `"flat"` - same as `all`, announce all CIDs of stored blocks, but without prioritizing anything

Default: `"all"`

Expand Down
17 changes: 17 additions & 0 deletions test/cli/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,23 @@ func TestProvider(t *testing.T) {
expectProviders(t, cid, nodes[0].PeerID().String(), nodes[1:]...)
})

t.Run("Reprovides with 'flat' strategy", func(t *testing.T) {
t.Parallel()

nodes := initNodes(t, 2, func(n *harness.Node) {
n.SetIPFSConfig("Reprovider.Strategy", "flat")
})
defer nodes.StopDaemons()

cid := nodes[0].IPFSAddStr(time.Now().String(), "--local")

expectNoProviders(t, cid, nodes[1:]...)

nodes[0].IPFS("bitswap", "reprovide")

expectProviders(t, cid, nodes[0].PeerID().String(), nodes[1:]...)
})

t.Run("Reprovides with 'pinned' strategy", func(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 9db17fb

Please sign in to comment.