@cryptotaxi247 / kubo / commits / 0f3dc1e84

core: Add config option for datastore read rehashing

License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

Jakub Sztandera committed Jun 24, 2016 at 22:10 UTC 0f3dc1e84a717210c5de43201a0c64ef099cc49d
2 files changed +14 -7
core/builder.go
+11 -5
@@ -130,16 +130,22 @@ func setupNode(ctx context.Context, n *IpfsNode, cfg *BuildCfg) error {
130 }
131
132 var err error
133 - n.Blockstore, err = bstore.WriteCached(bstore.NewBlockstore(n.Repo.Datastore()), kSizeBlockstoreWriteCache)
133 + bs := bstore.NewBlockstore(n.Repo.Datastore())
134 + n.Blockstore, err = bstore.WriteCached(bs, kSizeBlockstoreWriteCache)
135 if err != nil {
136 return err
137 }
138
139 + rcfg, err := n.Repo.Config()
140 + if err != nil {
141 + return err
142 + }
143 +
144 + if rcfg.Datastore.HashOnRead {
145 + bs.RuntimeHashing(true)
146 + }
147 +
148 if cfg.Online {
139 - rcfg, err := n.Repo.Config()
140 - if err != nil {
141 - return err
142 - }
149 do := setupDiscoveryOption(rcfg.Discovery)
150 if err := n.startOnlineServices(ctx, cfg.Routing, cfg.Host, do); err != nil {
151 return err
repo/config/datastore.go
+3 -2
@@ -15,8 +15,9 @@ type Datastore struct {
15 StorageGCWatermark int64 // in percentage to multiply on StorageMax
16 GCPeriod string // in ns, us, ms, s, m, h
17
18 - Params *json.RawMessage
19 - NoSync bool
18 + Params *json.RawMessage
19 + NoSync bool
20 + HashOnRead bool
21 }
22
23 func (d *Datastore) ParamData() []byte {