reprovider: add config option to set reprovide interval
License: MIT Signed-off-by: Jeromy <why@ipfs.io>
Jeromy committed
Aug 19, 2016 at 16:47 UTC
ad488c65254d61311f1a42eae158a6d2c787533b
5 files changed
+28
-1
core/core.go
+14
-1
@@ -169,7 +169,20 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
169
}
170
171
n.Reprovider = rp.NewReprovider(n.Routing, n.Blockstore)
172
- go n.Reprovider.ProvideEvery(ctx, kReprovideFrequency)
172
+
173
+ if cfg.Reprovider.Interval != "0" {
174
+ interval := kReprovideFrequency
175
+ if cfg.Reprovider.Interval != "" {
176
+ dur, err := time.ParseDuration(cfg.Reprovider.Interval)
177
+ if err != nil {
178
+ return err
179
+ }
180
+
181
+ interval = dur
182
+ }
183
+
184
+ go n.Reprovider.ProvideEvery(ctx, interval)
185
+ }
186
187
// setup local discovery
188
if do != nil {
docs/config.md
+4
@@ -15,6 +15,7 @@ a running daemon do not read the config file at runtime.
15
- [`Identity`](#identity)
16
- [`Ipns`](#ipns)
17
- [`Mounts`](#mounts)
18
+- [`ReproviderInterval`](#reproviderinterval)
19
- [`SupernodeRouting`](#supernoderouting)
20
- [`Swarm`](#swarm)
21
- [`Tour`](#tour)
@@ -192,6 +193,9 @@ Mountpoint for `/ipns/`.
193
- `FuseAllowOther`
194
Sets the FUSE allow other option on the mountpoint.
195
196
+## `ReproviderInterval`
197
+Sets the time between rounds of reproviding local content to the routing system. If unset, it defaults to 12 hours. If set to the value `"0"` it will disable content reproviding.
198
+
199
## `SupernodeRouting`
200
Deprecated.
201
repo/config/config.go
+2
@@ -29,6 +29,8 @@ type Config struct {
29
SupernodeRouting SupernodeClientConfig // local node's routing servers (if SupernodeRouting enabled)
30
API API // local node's API settings
31
Swarm SwarmConfig
32
+
33
+ Reprovider Reprovider
34
}
35
36
const (
repo/config/init.go
+3
@@ -68,6 +68,9 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
68
"Access-Control-Allow-Headers": []string{"X-Requested-With"},
69
},
70
},
71
+ Reprovider: Reprovider{
72
+ Interval: "12h",
73
+ },
74
}
75
76
return conf, nil
repo/config/reprovider.go
new
+5
@@ -0,0 +1,5 @@
1
+package config
2
+
3
+type Reprovider struct {
4
+ Interval string // Time period to reprovide locally stored objects to the network
5
+}