Skip to content

Commit

Permalink
config: make BlockKeyCacheSize an OptionalInteger
Browse files Browse the repository at this point in the history
  • Loading branch information
hsanjuan committed Dec 10, 2024
1 parent a23e331 commit 8111b82
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
12 changes: 9 additions & 3 deletions config/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ import (
"encoding/json"
)

// DefaultDataStoreDirectory is the directory to store all the local IPFS data.
const DefaultDataStoreDirectory = "datastore"
const (
// DefaultDataStoreDirectory is the directory to store all the local IPFS data.
DefaultDataStoreDirectory = "datastore"

// DefaultBlockKeyCacheSize is the size for the blockstore two-queue
// cache which caches block keys and sizes.
DefaultBlockKeyCacheSize = 64 << 10
)

// Datastore tracks the configuration of the datastore.
type Datastore struct {
Expand All @@ -23,7 +29,7 @@ type Datastore struct {

HashOnRead bool
BloomFilterSize int
BlockKeyCacheSize int
BlockKeyCacheSize OptionalInteger
}

// DataStorePath returns the default data store path given a configuration root
Expand Down
1 change: 0 additions & 1 deletion config/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ func DefaultDatastoreConfig() Datastore {
StorageGCWatermark: 90, // 90%
GCPeriod: "1h",
BloomFilterSize: 0,
BlockKeyCacheSize: 64 << 10, // 64KiB
Spec: flatfsSpec(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/node/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func LibP2P(bcfg *BuildCfg, cfg *config.Config, userResourceOverrides rcmgr.Part
func Storage(bcfg *BuildCfg, cfg *config.Config) fx.Option {
cacheOpts := blockstore.DefaultCacheOpts()
cacheOpts.HasBloomFilterSize = cfg.Datastore.BloomFilterSize
cacheOpts.HasTwoQueueCacheSize = cfg.Datastore.BlockKeyCacheSize
cacheOpts.HasTwoQueueCacheSize = int(cfg.Datastore.BlockKeyCacheSize.WithDefault(config.DefaultBlockKeyCacheSize))
if !bcfg.Permanent {
cacheOpts.HasBloomFilterSize = 0
}
Expand Down
2 changes: 1 addition & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ adjusted depending on the number of CIDs on disk.

Default: `65536` (64KiB)

Type: `integer` (non-negative, bytes)
Type: `optionalInteger` (non-negative, bytes)

### `Datastore.Spec`

Expand Down

0 comments on commit 8111b82

Please sign in to comment.