Skip to content

Commit

Permalink
Rename getFeeHistorical to calculateFee
Browse files Browse the repository at this point in the history
  • Loading branch information
chimp1984 committed Nov 14, 2021
1 parent fd4fb5b commit 5e940a5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions core/src/main/java/bisq/core/provider/mempool/TxValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private boolean checkFeeAmountBTC(String jsonTxt, Coin tradeAmount, boolean isMa
log.debug("BTC fee: {}", feeValue);

Param minFeeParam = isMaker ? Param.MIN_MAKER_FEE_BTC : Param.MIN_TAKER_FEE_BTC;
Coin expectedFee = getFeeHistorical(tradeAmount,
Coin expectedFee = calculateFee(tradeAmount,
isMaker ? getMakerFeeRateBtc(blockHeight) : getTakerFeeRateBtc(blockHeight),
minFeeParam);

Expand Down Expand Up @@ -264,7 +264,7 @@ private boolean checkFeeAmountBSQ(String jsonTxt, Coin tradeAmount, boolean isMa
throw new JsonSyntaxException("vin/vout missing data");
}
Param minFeeParam = isMaker ? Param.MIN_MAKER_FEE_BSQ : Param.MIN_TAKER_FEE_BSQ;
Coin expectedFee = getFeeHistorical(tradeAmount,
Coin expectedFee = calculateFee(tradeAmount,
isMaker ? getMakerFeeRateBsq(blockHeight) : getTakerFeeRateBsq(blockHeight),
minFeeParam);
long feeValue = jsonVIn0Value.getAsLong() - jsonFeeValue.getAsLong();
Expand Down Expand Up @@ -405,7 +405,7 @@ private static long getTxBlockHeight(String jsonTxt) {
return 0L; // in mempool, not confirmed yet
}

private Coin getFeeHistorical(Coin amount, Coin feeRatePerBtc, Param minFeeParam) {
private Coin calculateFee(Coin amount, Coin feeRatePerBtc, Param minFeeParam) {
double feePerBtcAsDouble = (double) feeRatePerBtc.value;
double amountAsDouble = amount != null ? (double) amount.value : 0;
double btcAsDouble = (double) Coin.COIN.value;
Expand Down Expand Up @@ -473,7 +473,7 @@ private boolean testWithFeeFromFilter(Coin tradeAmount,
Coin feeFromFilter,
Param minFeeParam) {
long actualFeeAsLong = actualFeeValue.value;
long feeFromFilterAsLong = getFeeHistorical(tradeAmount, feeFromFilter, minFeeParam).value;
long feeFromFilterAsLong = calculateFee(tradeAmount, feeFromFilter, minFeeParam).value;
double deviation = actualFeeAsLong / (double) feeFromFilterAsLong;
// It can be that the filter has not been updated immediately after DAO param change, so we need a tolerance
// Common change rate is 15-20%
Expand All @@ -487,13 +487,13 @@ private boolean feeExistsUsingDifferentDaoParam(Coin tradeAmount,
Param defaultFeeParam,
Param minFeeParam) {
for (Coin daoHistoricalRate : daoStateService.getParamChangeList(defaultFeeParam)) {
if (actualFeeValue.equals(getFeeHistorical(tradeAmount, daoHistoricalRate, minFeeParam))) {
if (actualFeeValue.equals(calculateFee(tradeAmount, daoHistoricalRate, minFeeParam))) {
return true;
}
}
// Finally, check the default rate used when we ask for the fee rate at genesis block height (it is hard coded in the Param enum)
Coin defaultRate = daoStateService.getParamValueAsCoin(defaultFeeParam, daoStateService.getGenesisBlockHeight());
return actualFeeValue.equals(getFeeHistorical(tradeAmount, defaultRate, minFeeParam));
return actualFeeValue.equals(calculateFee(tradeAmount, defaultRate, minFeeParam));
}

public TxValidator endResult(String title, boolean status) {
Expand Down

0 comments on commit 5e940a5

Please sign in to comment.