[#326] ir/settlement: Move the calculation of the minimum audit fee

Move control of the minimum cost of payment for the audit from the
implementation of the Exchanger to the place where the amount is calculated.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-01-28 20:05:52 +03:00 committed by Alex Vanin
parent 87c2c3ecc6
commit 2bca5879cd
2 changed files with 10 additions and 7 deletions

View file

@ -175,13 +175,8 @@ func (a auditSettlementDeps) Transfer(sender, recipient *owner.ID, amount *big.I
return
}
amount64 := amount.Int64()
if amount64 == 0 {
amount64 = 1
}
if err := a.balanceClient.TransferX(balanceClient.TransferPrm{
Amount: amount64,
Amount: amount.Int64(),
From: sender,
To: recipient,
Details: transferAuditDetails,

View file

@ -39,7 +39,11 @@ type singleResultCtx struct {
sumSGSize *big.Int
}
var bigGB = big.NewInt(1 << 30)
var (
bigGB = big.NewInt(1 << 30)
bigZero = big.NewInt(0)
bigOne = big.NewInt(1)
)
// Calculate calculates payments for audit results in a specific epoch of the network.
// Wraps the results in a money transfer transaction and sends it to the network.
@ -242,6 +246,10 @@ func (c *Calculator) fillTransferTable(ctx *singleResultCtx) bool {
fee := big.NewInt(0).Mul(price, ctx.sumSGSize)
fee.Div(fee, bigGB)
if fee.Cmp(bigZero) == 0 {
fee.Add(fee, bigOne)
}
ctx.txTable.transfer(&transferTx{
from: cnrOwner,
to: ownerID,