Skip to content

Commit

Permalink
rpc: rename variable to clarify its purpose
Browse files Browse the repository at this point in the history
  • Loading branch information
ffranr committed Jan 19, 2023
1 parent cf4ca47 commit e0623e7
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2261,9 +2261,10 @@ func (s *rpcServer) prepareLeasesResponse(ctx context.Context,
totalAmtPaid btcutil.Amount
)
for _, batch := range batches {
// Keep a tally of how many channels were created within each
// batch in order to estimate the chain fees paid.
numChans := 0
// Keep a tally of the total number of channels which were
// created within each batch in order to estimate the chain fees
// paid.
totalNumChannels := 0

// Keep track of the index for the first lease found for this
// batch. We'll use this to know where to start from when
Expand Down Expand Up @@ -2415,7 +2416,8 @@ func (s *rpcServer) prepareLeasesResponse(ctx context.Context,
SidecarChannel: isSidecarChannel,
})

numChans++
// Count the total number of channels.
totalNumChannels++
}

// Estimate the chain fees paid for the number of
Expand All @@ -2427,16 +2429,18 @@ func (s *rpcServer) prepareLeasesResponse(ctx context.Context,
// also take a look at the actual account version at the
// time of the batch.
chainFee := order.EstimateTraderFee(
uint32(numChans), batch.BatchTxFeeRate,
uint32(totalNumChannels), batch.BatchTxFeeRate,
account.VersionInitialNoVersion,
)

// We'll need to compute the chain fee paid for each
// lease. Since multiple leases can be created within a
// batch, we'll need to evenly distribute. We'll always
// apply the remainder to the first lease in the batch.
chainFeePerChan := chainFee / btcutil.Amount(numChans)
chainFeePerChanRem := chainFee % btcutil.Amount(numChans)
chainFeePerChan :=
chainFee / btcutil.Amount(totalNumChannels)
chainFeePerChanRem :=
chainFee % btcutil.Amount(totalNumChannels)
for i := firstIdxForBatch; i < len(rpcLeases); i++ {
chainFee := chainFeePerChan
if i == firstIdxForBatch {
Expand Down

0 comments on commit e0623e7

Please sign in to comment.