Skip to content

Commit

Permalink
pool: Calculating running total of dust.
Browse files Browse the repository at this point in the history
Collecting all dust payments in an array and summing them at the end is
unnecessary, the total can just be acculated inside the loop.
  • Loading branch information
jholdstock committed Nov 20, 2023
1 parent a8d5039 commit c2bf218
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions pool/paymentmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func (pm *PaymentMgr) calculatePayments(ratios map[string]*big.Rat, source *Paym
amtSansFees := total - fee
sansFees := new(big.Rat).SetInt64(int64(amtSansFees))
paymentTotal := dcrutil.Amount(0)
dustAmts := make([]dcrutil.Amount, 0)
var dustTotal dcrutil.Amount

// Calculate each participating account's portion of the amount after fees.
payments := make([]*Payment, 0)
Expand All @@ -292,7 +292,7 @@ func (pm *PaymentMgr) calculatePayments(ratios map[string]*big.Rat, source *Paym
// forfeited by their corresponding accounts and be added to
// the pool fee payout. This is intended to serve as a deterrent
// for contributing intermittent, sporadic work to the pool.
dustAmts = append(dustAmts, amt)
dustTotal += amt
} else {
payments = append(payments, NewPayment(account, source, amt, height,
estMaturity))
Expand All @@ -309,11 +309,6 @@ func (pm *PaymentMgr) calculatePayments(ratios map[string]*big.Rat, source *Paym

// Add a payout entry for pool fees, which includes any dust payments
// collected.
var dustTotal dcrutil.Amount
for _, amt := range dustAmts {
dustTotal += amt
}

feePayment := NewPayment(PoolFeesK, source, fee+dustTotal, height, estMaturity)
payments = append(payments, feePayment)

Expand Down

0 comments on commit c2bf218

Please sign in to comment.