Skip to content

Commit

Permalink
refactor: blobPaymentInfo logic flow
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Dec 20, 2024
1 parent 4ea02ce commit 08d61fb
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions api/clients/v2/accountant.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ func (a *Accountant) BlobPaymentInfo(ctx context.Context, numSymbols uint32, quo

overflowBinRecord := a.GetRelativeBinRecord(currentReservationPeriod + 2)
// Allow one overflow when the overflow bin is empty, the current usage and new length are both less than the limit
overflowBinRecord.Usage += relativeBinRecord.Usage - binLimit
if overflowBinRecord.Usage == relativeBinRecord.Usage-binLimit && relativeBinRecord.Usage-symbolUsage < binLimit && symbolUsage <= binLimit {
if overflowBinRecord.Usage == 0 && relativeBinRecord.Usage-symbolUsage < binLimit && symbolUsage <= binLimit {
overflowBinRecord.Usage += relativeBinRecord.Usage - binLimit
if err := QuorumCheck(quorumNumbers, a.reservation.QuorumNumbers); err != nil {
return 0, big.NewInt(0), err
}
Expand All @@ -98,7 +98,6 @@ func (a *Accountant) BlobPaymentInfo(ctx context.Context, numSymbols uint32, quo

// reservation not available, rollback reservation records, attempt on-demand
//todo: rollback on-demand if disperser respond with some type of rejection?
overflowBinRecord.Usage -= relativeBinRecord.Usage - binLimit
relativeBinRecord.Usage -= symbolUsage
incrementRequired := big.NewInt(int64(a.PaymentCharged(numSymbols)))
a.cumulativePayment.Add(a.cumulativePayment, incrementRequired)
Expand Down

0 comments on commit 08d61fb

Please sign in to comment.