Skip to content

Commit a84c859

Browse files
committed
core: Add config option for datastore read rehashing
License: MIT Signed-off-by: Jakub Sztandera <[email protected]>
1 parent f268696 commit a84c859

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

core/builder.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,16 @@ func setupNode(ctx context.Context, n *IpfsNode, cfg *BuildCfg) error {
130130
}
131131

132132
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+
136+
rcfg, err := n.Repo.Config()
137+
if err == nil {
138+
if rcfg.Datastore.HashOnRead {
139+
bs.RuntimeHashing(true)
140+
}
141+
}
142+
134143
if err != nil {
135144
return err
136145
}

repo/config/datastore.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ type Datastore struct {
1515
StorageGCWatermark int64 // in percentage to multiply on StorageMax
1616
GCPeriod string // in ns, us, ms, s, m, h
1717

18-
Params *json.RawMessage
19-
NoSync bool
18+
Params *json.RawMessage
19+
NoSync bool
20+
HashOnRead bool
2021
}
2122

2223
func (d *Datastore) ParamData() []byte {

0 commit comments

Comments
 (0)