From 43533c991e1b79f23f127343611b242fb7e2204b Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 22 Oct 2020 17:19:43 +0300 Subject: [PATCH] [#40] morph/netmap: Implement MaxObjectSize method on wrapper Signed-off-by: Leonard Lyubich --- pkg/morph/client/netmap/wrapper/config.go | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 pkg/morph/client/netmap/wrapper/config.go diff --git a/pkg/morph/client/netmap/wrapper/config.go b/pkg/morph/client/netmap/wrapper/config.go new file mode 100644 index 000000000..01b7124b7 --- /dev/null +++ b/pkg/morph/client/netmap/wrapper/config.go @@ -0,0 +1,29 @@ +package wrapper + +import ( + "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap" + "github.com/pkg/errors" +) + +const maxObjectSizeConfig = "MaxObjectSize" + +// MaxObjectSize receives max object size configuration +// value through the Netmap contract call. +func (w *Wrapper) MaxObjectSize() (uint64, error) { + args := netmap.ConfigArgs{} + args.SetKey([]byte(maxObjectSizeConfig)) + + vals, err := w.client.Config(args, netmap.IntegerAssert) + if err != nil { + return 0, errors.Wrapf(err, "(%T) could not get epoch number", w) + } + + v := vals.Value() + + sz, ok := v.(int64) + if !ok { + return 0, errors.Errorf("(%T) invalid epoch value type %T", w, v) + } + + return uint64(sz), nil +}