[#1312] morph/netmap: Fix panic during parameter parsing
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
8054311eee
commit
6c08ec9ca2
1 changed files with 16 additions and 9 deletions
|
@ -236,19 +236,19 @@ func WriteConfig(dst ConfigWriter, iterator func(func(key, val []byte) error) er
|
||||||
default:
|
default:
|
||||||
dst.UnknownParameter(k, val)
|
dst.UnknownParameter(k, val)
|
||||||
case maxObjectSizeConfig:
|
case maxObjectSizeConfig:
|
||||||
dst.MaxObjectSize(bigint.FromBytes(val).Uint64())
|
dst.MaxObjectSize(bytesToUint64(val))
|
||||||
case basicIncomeRateConfig:
|
case basicIncomeRateConfig:
|
||||||
dst.BasicIncomeRate(bigint.FromBytes(val).Uint64())
|
dst.BasicIncomeRate(bytesToUint64(val))
|
||||||
case auditFeeConfig:
|
case auditFeeConfig:
|
||||||
dst.AuditFee(bigint.FromBytes(val).Uint64())
|
dst.AuditFee(bytesToUint64(val))
|
||||||
case epochDurationConfig:
|
case epochDurationConfig:
|
||||||
dst.EpochDuration(bigint.FromBytes(val).Uint64())
|
dst.EpochDuration(bytesToUint64(val))
|
||||||
case containerFeeConfig:
|
case containerFeeConfig:
|
||||||
dst.ContainerFee(bigint.FromBytes(val).Uint64())
|
dst.ContainerFee(bytesToUint64(val))
|
||||||
case containerAliasFeeConfig:
|
case containerAliasFeeConfig:
|
||||||
dst.ContainerAliasFee(bigint.FromBytes(val).Uint64())
|
dst.ContainerAliasFee(bytesToUint64(val))
|
||||||
case etIterationsConfig:
|
case etIterationsConfig:
|
||||||
dst.EigenTrustIterations(bigint.FromBytes(val).Uint64())
|
dst.EigenTrustIterations(bytesToUint64(val))
|
||||||
case etAlphaConfig:
|
case etAlphaConfig:
|
||||||
v, err := strconv.ParseFloat(string(val), 64)
|
v, err := strconv.ParseFloat(string(val), 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -257,15 +257,22 @@ func WriteConfig(dst ConfigWriter, iterator func(func(key, val []byte) error) er
|
||||||
|
|
||||||
dst.EigenTrustAlpha(v)
|
dst.EigenTrustAlpha(v)
|
||||||
case irCandidateFeeConfig:
|
case irCandidateFeeConfig:
|
||||||
dst.InnerRingCandidateFee(bigint.FromBytes(val).Uint64())
|
dst.InnerRingCandidateFee(bytesToUint64(val))
|
||||||
case withdrawFeeConfig:
|
case withdrawFeeConfig:
|
||||||
dst.WithdrawFee(bigint.FromBytes(val).Uint64())
|
dst.WithdrawFee(bytesToUint64(val))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func bytesToUint64(val []byte) uint64 {
|
||||||
|
if len(val) == 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return bigint.FromBytes(val).Uint64()
|
||||||
|
}
|
||||||
|
|
||||||
// config performs the test invoke of get config value
|
// config performs the test invoke of get config value
|
||||||
// method of NeoFS Netmap contract.
|
// method of NeoFS Netmap contract.
|
||||||
func (c *Client) config(key []byte, assert func(stackitem.Item) (interface{}, error)) (interface{}, error) {
|
func (c *Client) config(key []byte, assert func(stackitem.Item) (interface{}, error)) (interface{}, error) {
|
||||||
|
|
Loading…
Reference in a new issue