2022-07-11 12:34:17 +00:00
|
|
|
package fstree
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Config is a wrapper over the config section
|
|
|
|
// which provides access to Blobovnicza configurations.
|
|
|
|
type Config config.Config
|
|
|
|
|
|
|
|
// DepthDefault is a default shallow dir depth.
|
|
|
|
const DepthDefault = 4
|
|
|
|
|
|
|
|
// From wraps config section into Config.
|
|
|
|
func From(c *config.Config) *Config {
|
|
|
|
return (*Config)(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Type returns the storage type.
|
|
|
|
func (x *Config) Type() string {
|
2022-09-20 12:42:56 +00:00
|
|
|
return fstree.Type
|
2022-07-11 12:34:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Depth returns the value of "depth" config parameter.
|
|
|
|
//
|
|
|
|
// Returns DepthDefault if the value is out of
|
|
|
|
// [1:fstree.MaxDepth] range.
|
2022-09-26 16:38:03 +00:00
|
|
|
func (x *Config) Depth() uint64 {
|
|
|
|
d := config.UintSafe(
|
2022-07-11 12:34:17 +00:00
|
|
|
(*config.Config)(x),
|
|
|
|
"depth",
|
|
|
|
)
|
|
|
|
|
|
|
|
if d >= 1 && d <= fstree.MaxDepth {
|
2022-09-26 16:38:03 +00:00
|
|
|
return d
|
2022-07-11 12:34:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return DepthDefault
|
|
|
|
}
|