From c33512d9763c398f3ed9b93195df44798abbf17c Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Thu, 15 Apr 2021 09:42:35 +0300 Subject: [PATCH] [#478] morph/client: Add more global config value getters Including: - typo fix for `BasicIncomeRate` method - epoch duration getter, - container fee getter, - EigenTrust iterations getter. Signed-off-by: Alex Vanin --- pkg/innerring/config/config.go | 2 +- pkg/morph/client/netmap/wrapper/config.go | 41 +++++++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/pkg/innerring/config/config.go b/pkg/innerring/config/config.go index f7c556cb..0ecaa457 100644 --- a/pkg/innerring/config/config.go +++ b/pkg/innerring/config/config.go @@ -35,7 +35,7 @@ func (c *GlobalConfig) BasicIncomeRate() (uint64, error) { return value, nil } - return c.nm.BasinIncomeRate() + return c.nm.BasicIncomeRate() } func (c *GlobalConfig) AuditFee() (uint64, error) { diff --git a/pkg/morph/client/netmap/wrapper/config.go b/pkg/morph/client/netmap/wrapper/config.go index f4640d8b..8cedd5f5 100644 --- a/pkg/morph/client/netmap/wrapper/config.go +++ b/pkg/morph/client/netmap/wrapper/config.go @@ -8,7 +8,10 @@ import ( const ( maxObjectSizeConfig = "MaxObjectSize" basicIncomeRateConfig = "BasicIncomeRate" - auditFee = "AuditFee" + auditFeeConfig = "AuditFee" + epochDurationConfig = "EpochDuration" + containerFeeConfig = "ContainerFee" + etIterationsConfig = "EigenTrustIterations" ) // MaxObjectSize receives max object size configuration @@ -24,7 +27,7 @@ func (w *Wrapper) MaxObjectSize() (uint64, error) { // BasicIncomeRate returns basic income rate configuration value from network // config in netmap contract. -func (w *Wrapper) BasinIncomeRate() (uint64, error) { +func (w *Wrapper) BasicIncomeRate() (uint64, error) { rate, err := w.readUInt64Config(basicIncomeRateConfig) if err != nil { return 0, errors.Wrapf(err, "(%T) could not get basic income rate", w) @@ -36,7 +39,7 @@ func (w *Wrapper) BasinIncomeRate() (uint64, error) { // AuditFee returns audit fee configuration value from network // config in netmap contract. func (w *Wrapper) AuditFee() (uint64, error) { - fee, err := w.readUInt64Config(auditFee) + fee, err := w.readUInt64Config(auditFeeConfig) if err != nil { return 0, errors.Wrapf(err, "(%T) could not get audit fee", w) } @@ -44,6 +47,38 @@ func (w *Wrapper) AuditFee() (uint64, error) { return fee, nil } +// EpochDuration returns number of sidechain blocks per one NeoFS epoch. +func (w *Wrapper) EpochDuration() (uint64, error) { + epochDuration, err := w.readUInt64Config(epochDurationConfig) + if err != nil { + return 0, errors.Wrapf(err, "(%T) could not get epoch duration", w) + } + + return epochDuration, nil +} + +// ContainerFee returns fee paid by container owner to each alphabet node +// for container registration. +func (w *Wrapper) ContainerFee() (uint64, error) { + fee, err := w.readUInt64Config(containerFeeConfig) + if err != nil { + return 0, errors.Wrapf(err, "(%T) could not get container fee", w) + } + + return fee, nil +} + +// EigenTrustIterations returns global configuration value of iteration cycles +// for EigenTrust algorithm per epoch. +func (w *Wrapper) EigenTrustIterations() (uint64, error) { + iterations, err := w.readUInt64Config(etIterationsConfig) + if err != nil { + return 0, errors.Wrapf(err, "(%T) could not get eigen trust iterations", w) + } + + return iterations, nil +} + func (w *Wrapper) readUInt64Config(key string) (uint64, error) { args := netmap.ConfigArgs{} args.SetKey([]byte(key))