[#43] cmd/neofs-node: Fetch max object size from config

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-09-29 15:38:44 +03:00
parent e158497560
commit 13080aa7a1
2 changed files with 10 additions and 2 deletions

View file

@ -53,6 +53,8 @@ const (
// config keys for cfgContainer
cfgContainerContract = "container.scripthash"
cfgContainerFee = "container.fee"
cfgMaxObjectSize = "node.maxobjectsize" // get value from chain
)
type cfg struct {
@ -125,6 +127,8 @@ type cfgObject struct {
netMapStorage netmapCore.Source
cnrStorage container.Source
maxObjectSize uint64
}
const (
@ -179,6 +183,9 @@ func initCfg(path string) *cfg {
bootType: StorageNode,
attributes: parseAttributes(viperCfg),
},
cfgObject: cfgObject{
maxObjectSize: viperCfg.GetUint64(cfgMaxObjectSize),
},
localAddr: netAddr,
}
}
@ -208,6 +215,7 @@ func defaultConfiguration(v *viper.Viper) {
// fixme: all hardcoded private keys must be removed
v.SetDefault(cfgNodeKey, "Kwk6k2eC3L3QuPvD8aiaNyoSXgQ2YL1bwS5CP1oKoA9waeAze97s")
v.SetDefault(cfgBootstrapAddress, "") // address to bootstrap with
v.SetDefault(cfgMaxObjectSize, 1024*1024) // default max object size 1 megabyte
v.SetDefault(cfgMorphRPCAddress, "http://morph_chain.localtest.nspcc.ru:30333/")
v.SetDefault(cfgListenAddress, "127.0.0.1:50501") // listen address

View file

@ -160,7 +160,7 @@ func initObjectService(c *cfg) {
sPut := putsvc.NewService(
putsvc.WithKeyStorage(keyStorage),
putsvc.WithMaxSizeSource(&maxSzSrc{3}),
putsvc.WithMaxSizeSource(&maxSzSrc{c.cfgObject.maxObjectSize}),
putsvc.WithLocalStorage(ls),
putsvc.WithContainerSource(c.cfgObject.cnrStorage),
putsvc.WithNetworkMapSource(c.cfgObject.netMapStorage),