forked from TrueCloudLab/frostfs-node
47 lines
1.6 KiB
Go
47 lines
1.6 KiB
Go
package morph
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
func getDefaultNetmapContractConfigMap() map[string]any {
|
|
m := make(map[string]any)
|
|
m[netmapEpochKey] = viper.GetInt64(epochDurationInitFlag)
|
|
m[netmapMaxObjectSizeKey] = viper.GetInt64(maxObjectSizeInitFlag)
|
|
m[netmapAuditFeeKey] = viper.GetInt64(auditFeeInitFlag)
|
|
m[netmapContainerFeeKey] = viper.GetInt64(containerFeeInitFlag)
|
|
m[netmapContainerAliasFeeKey] = viper.GetInt64(containerAliasFeeInitFlag)
|
|
m[netmapEigenTrustIterationsKey] = int64(defaultEigenTrustIterations)
|
|
m[netmapEigenTrustAlphaKey] = defaultEigenTrustAlpha
|
|
m[netmapBasicIncomeRateKey] = viper.GetInt64(incomeRateInitFlag)
|
|
m[netmapInnerRingCandidateFeeKey] = viper.GetInt64(candidateFeeInitFlag)
|
|
m[netmapWithdrawFeeKey] = viper.GetInt64(withdrawFeeInitFlag)
|
|
m[netmapHomomorphicHashDisabledKey] = viper.GetBool(homomorphicHashDisabledInitFlag)
|
|
m[netmapMaintenanceAllowedKey] = viper.GetBool(maintenanceModeAllowedInitFlag)
|
|
return m
|
|
}
|
|
|
|
func parseConfigFromNetmapContract(arr []stackitem.Item) (map[string][]byte, error) {
|
|
m := make(map[string][]byte, len(arr))
|
|
for _, param := range arr {
|
|
tuple, ok := param.Value().([]stackitem.Item)
|
|
if !ok || len(tuple) != 2 {
|
|
return nil, errors.New("invalid ListConfig response from netmap contract")
|
|
}
|
|
|
|
k, err := tuple[0].TryBytes()
|
|
if err != nil {
|
|
return nil, errors.New("invalid config key from netmap contract")
|
|
}
|
|
|
|
v, err := tuple[1].TryBytes()
|
|
if err != nil {
|
|
return nil, invalidConfigValueErr(string(k))
|
|
}
|
|
m[string(k)] = v
|
|
}
|
|
return m, nil
|
|
}
|