[#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:
parent
87c2c3ecc6
commit
2bca5879cd
2 changed files with 10 additions and 7 deletions
|
@ -175,13 +175,8 @@ func (a auditSettlementDeps) Transfer(sender, recipient *owner.ID, amount *big.I
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
amount64 := amount.Int64()
|
|
||||||
if amount64 == 0 {
|
|
||||||
amount64 = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := a.balanceClient.TransferX(balanceClient.TransferPrm{
|
if err := a.balanceClient.TransferX(balanceClient.TransferPrm{
|
||||||
Amount: amount64,
|
Amount: amount.Int64(),
|
||||||
From: sender,
|
From: sender,
|
||||||
To: recipient,
|
To: recipient,
|
||||||
Details: transferAuditDetails,
|
Details: transferAuditDetails,
|
||||||
|
|
|
@ -39,7 +39,11 @@ type singleResultCtx struct {
|
||||||
sumSGSize *big.Int
|
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.
|
// 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.
|
// 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 := big.NewInt(0).Mul(price, ctx.sumSGSize)
|
||||||
fee.Div(fee, bigGB)
|
fee.Div(fee, bigGB)
|
||||||
|
|
||||||
|
if fee.Cmp(bigZero) == 0 {
|
||||||
|
fee.Add(fee, bigOne)
|
||||||
|
}
|
||||||
|
|
||||||
ctx.txTable.transfer(&transferTx{
|
ctx.txTable.transfer(&transferTx{
|
||||||
from: cnrOwner,
|
from: cnrOwner,
|
||||||
to: ownerID,
|
to: ownerID,
|
||||||
|
|
Loading…
Reference in a new issue