mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-10 18:57:57 +08:00
feat: increase default Reprovider.Interval (#9326)
* increase republish interval based on RFM17 * refactor(config): switch to implicit default Co-authored-by: Marcin Rataj <lidel@lidel.org>
This commit is contained in:
parent
bf61e639e9
commit
72bad5c060
@ -76,8 +76,8 @@ func InitWithIdentity(identity Identity) (*Config, error) {
|
||||
APICommands: []string{},
|
||||
},
|
||||
Reprovider: Reprovider{
|
||||
Interval: "12h",
|
||||
Strategy: "all",
|
||||
Interval: nil,
|
||||
Strategy: nil,
|
||||
},
|
||||
Pinning: Pinning{
|
||||
RemoteServices: map[string]RemotePinningService{},
|
||||
|
||||
@ -176,7 +176,7 @@ fetching may be degraded.
|
||||
Transform: func(c *Config) error {
|
||||
c.Routing.Type = "dhtclient"
|
||||
c.AutoNAT.ServiceMode = AutoNATServiceDisabled
|
||||
c.Reprovider.Interval = "0"
|
||||
c.Reprovider.Interval = NewOptionalDuration(0)
|
||||
|
||||
lowWater := int64(20)
|
||||
highWater := int64(40)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package config
|
||||
|
||||
type Reprovider struct {
|
||||
Interval string // Time period to reprovide locally stored objects to the network
|
||||
Strategy string // Which keys to announce
|
||||
Interval *OptionalDuration `json:",omitempty"` // Time period to reprovide locally stored objects to the network
|
||||
Strategy *OptionalString `json:",omitempty"` // Which keys to announce
|
||||
}
|
||||
|
||||
@ -218,6 +218,11 @@ type OptionalDuration struct {
|
||||
value *time.Duration
|
||||
}
|
||||
|
||||
// NewOptionalDuration returns an OptionalDuration from a string
|
||||
func NewOptionalDuration(d time.Duration) *OptionalDuration {
|
||||
return &OptionalDuration{value: &d}
|
||||
}
|
||||
|
||||
func (d *OptionalDuration) UnmarshalJSON(input []byte) error {
|
||||
switch string(input) {
|
||||
case "null", "undefined", "\"null\"", "", "default", "\"\"", "\"default\"":
|
||||
|
||||
@ -291,7 +291,12 @@ func Online(bcfg *BuildCfg, cfg *config.Config) fx.Option {
|
||||
fx.Provide(p2p.New),
|
||||
|
||||
LibP2P(bcfg, cfg),
|
||||
OnlineProviders(cfg.Experimental.StrategicProviding, cfg.Experimental.AcceleratedDHTClient, cfg.Reprovider.Strategy, cfg.Reprovider.Interval),
|
||||
OnlineProviders(
|
||||
cfg.Experimental.StrategicProviding,
|
||||
cfg.Experimental.AcceleratedDHTClient,
|
||||
cfg.Reprovider.Strategy.WithDefault(DefaultReproviderStrategy),
|
||||
cfg.Reprovider.Interval.WithDefault(DefaultReproviderInterval),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@ -304,7 +309,12 @@ func Offline(cfg *config.Config) fx.Option {
|
||||
fx.Provide(libp2p.Routing),
|
||||
fx.Provide(libp2p.ContentRouting),
|
||||
fx.Provide(libp2p.OfflineRouting),
|
||||
OfflineProviders(cfg.Experimental.StrategicProviding, cfg.Experimental.AcceleratedDHTClient, cfg.Reprovider.Strategy, cfg.Reprovider.Interval),
|
||||
OfflineProviders(
|
||||
cfg.Experimental.StrategicProviding,
|
||||
cfg.Experimental.AcceleratedDHTClient,
|
||||
cfg.Reprovider.Strategy.WithDefault(DefaultReproviderStrategy),
|
||||
cfg.Reprovider.Interval.WithDefault(DefaultReproviderInterval),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -18,7 +18,8 @@ import (
|
||||
irouting "github.com/ipfs/kubo/routing"
|
||||
)
|
||||
|
||||
const kReprovideFrequency = time.Hour * 12
|
||||
const DefaultReproviderInterval = time.Hour * 22 // https://github.com/ipfs/kubo/pull/9326
|
||||
const DefaultReproviderStrategy = "all"
|
||||
|
||||
// SIMPLE
|
||||
|
||||
@ -61,20 +62,10 @@ func SimpleProviderSys(isOnline bool) interface{} {
|
||||
}
|
||||
|
||||
// BatchedProviderSys creates new provider system
|
||||
func BatchedProviderSys(isOnline bool, reprovideInterval string) interface{} {
|
||||
func BatchedProviderSys(isOnline bool, reprovideInterval time.Duration) interface{} {
|
||||
return func(lc fx.Lifecycle, cr irouting.ProvideManyRouter, q *q.Queue, keyProvider simple.KeyChanFunc, repo repo.Repo) (provider.System, error) {
|
||||
reprovideIntervalDuration := kReprovideFrequency
|
||||
if reprovideInterval != "" {
|
||||
dur, err := time.ParseDuration(reprovideInterval)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
reprovideIntervalDuration = dur
|
||||
}
|
||||
|
||||
sys, err := batched.New(cr, q,
|
||||
batched.ReproviderInterval(reprovideIntervalDuration),
|
||||
batched.ReproviderInterval(reprovideInterval),
|
||||
batched.Datastore(repo.Datastore()),
|
||||
batched.KeyProvider(keyProvider))
|
||||
if err != nil {
|
||||
@ -100,7 +91,7 @@ func BatchedProviderSys(isOnline bool, reprovideInterval string) interface{} {
|
||||
// ONLINE/OFFLINE
|
||||
|
||||
// OnlineProviders groups units managing provider routing records online
|
||||
func OnlineProviders(useStrategicProviding bool, useBatchedProviding bool, reprovideStrategy string, reprovideInterval string) fx.Option {
|
||||
func OnlineProviders(useStrategicProviding bool, useBatchedProviding bool, reprovideStrategy string, reprovideInterval time.Duration) fx.Option {
|
||||
if useStrategicProviding {
|
||||
return fx.Provide(provider.NewOfflineProvider)
|
||||
}
|
||||
@ -113,7 +104,7 @@ func OnlineProviders(useStrategicProviding bool, useBatchedProviding bool, repro
|
||||
}
|
||||
|
||||
// OfflineProviders groups units managing provider routing records offline
|
||||
func OfflineProviders(useStrategicProviding bool, useBatchedProviding bool, reprovideStrategy string, reprovideInterval string) fx.Option {
|
||||
func OfflineProviders(useStrategicProviding bool, useBatchedProviding bool, reprovideStrategy string, reprovideInterval time.Duration) fx.Option {
|
||||
if useStrategicProviding {
|
||||
return fx.Provide(provider.NewOfflineProvider)
|
||||
}
|
||||
@ -126,17 +117,7 @@ func OfflineProviders(useStrategicProviding bool, useBatchedProviding bool, repr
|
||||
}
|
||||
|
||||
// SimpleProviders creates the simple provider/reprovider dependencies
|
||||
func SimpleProviders(reprovideStrategy string, reprovideInterval string) fx.Option {
|
||||
reproviderInterval := kReprovideFrequency
|
||||
if reprovideInterval != "" {
|
||||
dur, err := time.ParseDuration(reprovideInterval)
|
||||
if err != nil {
|
||||
return fx.Error(err)
|
||||
}
|
||||
|
||||
reproviderInterval = dur
|
||||
}
|
||||
|
||||
func SimpleProviders(reprovideStrategy string, reproviderInterval time.Duration) fx.Option {
|
||||
var keyProvider fx.Option
|
||||
switch reprovideStrategy {
|
||||
case "all":
|
||||
|
||||
@ -11,6 +11,7 @@ Below is an outline of all that is in this release, so you get a sense of all th
|
||||
- [Overview](#overview)
|
||||
- [🔦 Highlights](#-highlights)
|
||||
- [(DAG-)JSON and (DAG-)CBOR Response Formats on Gateways](#dag-json-and-dag-cbor-response-formats-on-gateways)
|
||||
- [Increased `Reprovider.Interval`](#increased-reproviderinterval)
|
||||
- [Changelog](#changelog)
|
||||
- [Contributors](#contributors)
|
||||
|
||||
@ -68,6 +69,16 @@ $ curl "http://127.0.0.1:8080/ipfs/$DIR_CID?format=dag-json" | jq
|
||||
}
|
||||
```
|
||||
|
||||
#### Increased `Reprovider.Interval`
|
||||
|
||||
Default changed from 12h to 22h.
|
||||
We also stopped `ipfs init` from hardcoding the default value in user config, allowing Kubo to adjust implicit default in future releases.
|
||||
|
||||
Rationale for increasing this can be found in [RFM 17: Provider Record Livenes Report](https://github.com/protocol/network-measurements/blob/master/results/rfm17-provider-record-liveness.md)
|
||||
and [kubo#9326](https://github.com/ipfs/kubo/pull/9326).
|
||||
|
||||
Learn more: [`Reprovider` config](https://github.com/ipfs/go-ipfs/blob/master/docs/config.md#reprovider)
|
||||
|
||||
### Changelog
|
||||
|
||||
### Contributors
|
||||
|
||||
Loading…
Reference in New Issue
Block a user