From e0623e7cddb568d1cc12ef5128e7b5164ff6829e Mon Sep 17 00:00:00 2001 From: ffranr Date: Thu, 19 Jan 2023 10:42:55 +0000 Subject: [PATCH] rpc: rename variable to clarify its purpose --- rpcserver.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/rpcserver.go b/rpcserver.go index 146f02a1f..f78222197 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -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 @@ -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 @@ -2427,7 +2429,7 @@ 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, ) @@ -2435,8 +2437,10 @@ func (s *rpcServer) prepareLeasesResponse(ctx context.Context, // 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 {