From 13080aa7a13b0837170a3d9eea1cc430f6ea6a68 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 29 Sep 2020 15:38:44 +0300 Subject: [PATCH] [#43] cmd/neofs-node: Fetch max object size from config Signed-off-by: Alex Vanin --- cmd/neofs-node/config.go | 10 +++++++++- cmd/neofs-node/object.go | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index e614e3237..8216b7490 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -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, } } @@ -207,7 +214,8 @@ func initViper(path string) *viper.Viper { 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(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 diff --git a/cmd/neofs-node/object.go b/cmd/neofs-node/object.go index 70ea550d6..4979bf308 100644 --- a/cmd/neofs-node/object.go +++ b/cmd/neofs-node/object.go @@ -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),