From ad488c65254d61311f1a42eae158a6d2c787533b Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 19 Aug 2016 16:47:29 -0700 Subject: [PATCH] reprovider: add config option to set reprovide interval License: MIT Signed-off-by: Jeromy --- core/core.go | 15 ++++++++++++++- docs/config.md | 4 ++++ repo/config/config.go | 2 ++ repo/config/init.go | 3 +++ repo/config/reprovider.go | 5 +++++ 5 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 repo/config/reprovider.go diff --git a/core/core.go b/core/core.go index a7c285e19..d20ec8204 100644 --- a/core/core.go +++ b/core/core.go @@ -169,7 +169,20 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin } n.Reprovider = rp.NewReprovider(n.Routing, n.Blockstore) - go n.Reprovider.ProvideEvery(ctx, kReprovideFrequency) + + if cfg.Reprovider.Interval != "0" { + interval := kReprovideFrequency + if cfg.Reprovider.Interval != "" { + dur, err := time.ParseDuration(cfg.Reprovider.Interval) + if err != nil { + return err + } + + interval = dur + } + + go n.Reprovider.ProvideEvery(ctx, interval) + } // setup local discovery if do != nil { diff --git a/docs/config.md b/docs/config.md index 844fb9984..7b4948d32 100644 --- a/docs/config.md +++ b/docs/config.md @@ -15,6 +15,7 @@ a running daemon do not read the config file at runtime. - [`Identity`](#identity) - [`Ipns`](#ipns) - [`Mounts`](#mounts) +- [`ReproviderInterval`](#reproviderinterval) - [`SupernodeRouting`](#supernoderouting) - [`Swarm`](#swarm) - [`Tour`](#tour) @@ -192,6 +193,9 @@ Mountpoint for `/ipns/`. - `FuseAllowOther` Sets the FUSE allow other option on the mountpoint. +## `ReproviderInterval` +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. + ## `SupernodeRouting` Deprecated. diff --git a/repo/config/config.go b/repo/config/config.go index 4488bba08..4a3995a99 100644 --- a/repo/config/config.go +++ b/repo/config/config.go @@ -29,6 +29,8 @@ type Config struct { SupernodeRouting SupernodeClientConfig // local node's routing servers (if SupernodeRouting enabled) API API // local node's API settings Swarm SwarmConfig + + Reprovider Reprovider } const ( diff --git a/repo/config/init.go b/repo/config/init.go index 5123e39e9..ac0c8f23b 100644 --- a/repo/config/init.go +++ b/repo/config/init.go @@ -68,6 +68,9 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { "Access-Control-Allow-Headers": []string{"X-Requested-With"}, }, }, + Reprovider: Reprovider{ + Interval: "12h", + }, } return conf, nil diff --git a/repo/config/reprovider.go b/repo/config/reprovider.go new file mode 100644 index 000000000..53cf293ab --- /dev/null +++ b/repo/config/reprovider.go @@ -0,0 +1,5 @@ +package config + +type Reprovider struct { + Interval string // Time period to reprovide locally stored objects to the network +}