forked from TrueCloudLab/frostfs-node
[#452] innerring: Use reputation processor
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
09e4479d44
commit
b18da34b55
3 changed files with 56 additions and 6 deletions
|
@ -67,6 +67,7 @@ func defaultConfiguration(cfg *viper.Viper) {
|
||||||
cfg.SetDefault("contracts.container", "")
|
cfg.SetDefault("contracts.container", "")
|
||||||
cfg.SetDefault("contracts.audit", "")
|
cfg.SetDefault("contracts.audit", "")
|
||||||
cfg.SetDefault("contracts.proxy", "")
|
cfg.SetDefault("contracts.proxy", "")
|
||||||
|
cfg.SetDefault("contracts.reputation", "")
|
||||||
// alphabet contracts
|
// alphabet contracts
|
||||||
cfg.SetDefault("contracts.alphabet.amount", 7)
|
cfg.SetDefault("contracts.alphabet.amount", 7)
|
||||||
|
|
||||||
|
@ -87,6 +88,7 @@ func defaultConfiguration(cfg *viper.Viper) {
|
||||||
cfg.SetDefault("workers.neofs", "10")
|
cfg.SetDefault("workers.neofs", "10")
|
||||||
cfg.SetDefault("workers.container", "10")
|
cfg.SetDefault("workers.container", "10")
|
||||||
cfg.SetDefault("workers.alphabet", "10")
|
cfg.SetDefault("workers.alphabet", "10")
|
||||||
|
cfg.SetDefault("workers.reputation", "10")
|
||||||
|
|
||||||
cfg.SetDefault("netmap_cleaner.enabled", false)
|
cfg.SetDefault("netmap_cleaner.enabled", false)
|
||||||
cfg.SetDefault("netmap_cleaner.threshold", 3)
|
cfg.SetDefault("netmap_cleaner.threshold", 3)
|
||||||
|
|
|
@ -19,6 +19,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/governance"
|
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/governance"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/neofs"
|
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/neofs"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/netmap"
|
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/netmap"
|
||||||
|
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/reputation"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/settlement"
|
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/settlement"
|
||||||
auditSettlement "github.com/nspcc-dev/neofs-node/pkg/innerring/processors/settlement/audit"
|
auditSettlement "github.com/nspcc-dev/neofs-node/pkg/innerring/processors/settlement/audit"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/timers"
|
"github.com/nspcc-dev/neofs-node/pkg/innerring/timers"
|
||||||
|
@ -92,6 +93,7 @@ type (
|
||||||
container util.Uint160 // in morph
|
container util.Uint160 // in morph
|
||||||
audit util.Uint160 // in morph
|
audit util.Uint160 // in morph
|
||||||
proxy util.Uint160 // in morph
|
proxy util.Uint160 // in morph
|
||||||
|
reputation util.Uint160 // in morph
|
||||||
|
|
||||||
alphabet alphabetContracts // in morph
|
alphabet alphabetContracts // in morph
|
||||||
}
|
}
|
||||||
|
@ -329,6 +331,11 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repClient, err := invoke.NewReputationClient(server.morphClient, server.contracts.reputation)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// create global runtime config reader
|
// create global runtime config reader
|
||||||
globalConfig := config.NewGlobalConfigReader(cfg, nmClient)
|
globalConfig := config.NewGlobalConfigReader(cfg, nmClient)
|
||||||
|
|
||||||
|
@ -551,6 +558,24 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create reputation processor
|
||||||
|
reputationProcessor, err := reputation.New(&reputation.Params{
|
||||||
|
Log: log,
|
||||||
|
PoolSize: cfg.GetInt("workers.reputation"),
|
||||||
|
ReputationContract: server.contracts.reputation,
|
||||||
|
EpochState: server,
|
||||||
|
AlphabetState: server,
|
||||||
|
ReputationWrapper: repClient,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = bindMorphProcessor(reputationProcessor, server)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// todo: create vivid id component
|
// todo: create vivid id component
|
||||||
|
|
||||||
// initialize epoch timers
|
// initialize epoch timers
|
||||||
|
@ -642,6 +667,7 @@ func parseContracts(cfg *viper.Viper) (*contracts, error) {
|
||||||
containerContractStr := cfg.GetString("contracts.container")
|
containerContractStr := cfg.GetString("contracts.container")
|
||||||
auditContractStr := cfg.GetString("contracts.audit")
|
auditContractStr := cfg.GetString("contracts.audit")
|
||||||
proxyContractStr := cfg.GetString("contracts.proxy")
|
proxyContractStr := cfg.GetString("contracts.proxy")
|
||||||
|
reputationContractStr := cfg.GetString("contracts.reputation")
|
||||||
|
|
||||||
result.netmap, err = util.Uint160DecodeStringLE(netmapContractStr)
|
result.netmap, err = util.Uint160DecodeStringLE(netmapContractStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -673,6 +699,11 @@ func parseContracts(cfg *viper.Viper) (*contracts, error) {
|
||||||
return nil, errors.Wrap(err, "ir: can't read proxy script-hash")
|
return nil, errors.Wrap(err, "ir: can't read proxy script-hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.reputation, err = util.Uint160DecodeStringLE(reputationContractStr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "ir: can't read reputation script-hash")
|
||||||
|
}
|
||||||
|
|
||||||
result.alphabet, err = parseAlphabetContracts(cfg)
|
result.alphabet, err = parseAlphabetContracts(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -13,6 +13,8 @@ import (
|
||||||
wrapContainer "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
|
wrapContainer "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
|
||||||
morphNetmap "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
|
morphNetmap "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
|
||||||
wrapNetmap "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap/wrapper"
|
wrapNetmap "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap/wrapper"
|
||||||
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation"
|
||||||
|
reputationWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation/wrapper"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -70,3 +72,18 @@ func NewBalanceClient(cli *client.Client, contract util.Uint160) (*balanceWrappe
|
||||||
|
|
||||||
return balanceWrapper.New(enhancedBalanceClient)
|
return balanceWrapper.New(enhancedBalanceClient)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewReputationClient creates wrapper to work with reputation contract.
|
||||||
|
func NewReputationClient(cli *client.Client, contract util.Uint160) (*reputationWrapper.ClientWrapper, error) {
|
||||||
|
staticClient, err := client.NewStatic(cli, contract, 0)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "could not create static client of reputation contract")
|
||||||
|
}
|
||||||
|
|
||||||
|
enhancedRepurationClient, err := reputation.New(staticClient)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "could not create reputation contract client")
|
||||||
|
}
|
||||||
|
|
||||||
|
return reputationWrapper.WrapClient(enhancedRepurationClient), nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue