From 1f3bb33db81ac6d3af65643ce26cd4c57f9910c6 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Thu, 29 Apr 2021 16:37:16 +0300 Subject: [PATCH] [#486] innerring: Add fee configuration When notary disabled, inner ring should be able to configure extra fee for vote collections inside the contracts. Previously these values were hardcoded, however we might want to change them depending on a environment. Signed-off-by: Alex Vanin --- cmd/neofs-ir/defaults.go | 4 ++++ pkg/innerring/config/fee.go | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 pkg/innerring/config/fee.go diff --git a/cmd/neofs-ir/defaults.go b/cmd/neofs-ir/defaults.go index 58079e44a4..cb5f05f537 100644 --- a/cmd/neofs-ir/defaults.go +++ b/cmd/neofs-ir/defaults.go @@ -117,4 +117,8 @@ func defaultConfiguration(cfg *viper.Viper) { cfg.SetDefault("indexer.cache_timeout", 15*time.Second) cfg.SetDefault("locode.db.path", "") + + // extra fee values for working mode without notary contract + cfg.SetDefault("fee.main_chain", 5000_0000) // 0.5 Fixed8 + cfg.SetDefault("fee.side_chain", 2_0000_0000) // 2.0 Fixed8 } diff --git a/pkg/innerring/config/fee.go b/pkg/innerring/config/fee.go new file mode 100644 index 0000000000..f448f1ba5b --- /dev/null +++ b/pkg/innerring/config/fee.go @@ -0,0 +1,27 @@ +package config + +import ( + "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" + "github.com/spf13/viper" +) + +// FeeConfig is an instance that returns extra fee values for contract +// invocations without notary support. +type FeeConfig struct { + mainchain, sidechain fixedn.Fixed8 +} + +func NewFeeConfig(v *viper.Viper) *FeeConfig { + return &FeeConfig{ + mainchain: fixedn.Fixed8(v.GetInt64("fee.main_chain")), + sidechain: fixedn.Fixed8(v.GetInt64("fee.side_chain")), + } +} + +func (f FeeConfig) MainChainFee() fixedn.Fixed8 { + return f.mainchain +} + +func (f FeeConfig) SideChainFee() fixedn.Fixed8 { + return f.sidechain +}