Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obtain trade fee settings from filter #6048

Merged
merged 1 commit into from Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/java/bisq/core/app/DomainInitialisation.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public void initDomainServices(Consumer<String> rejectedTxErrorMessageHandler,

p2PService.onAllServicesInitialized();

feeService.onAllServicesInitialized();
feeService.onAllServicesInitialized(filterManager);

if (DevEnv.isDaoActivated()) {
daoSetup.onAllServicesInitialized(errorMessage -> {
Expand Down
30 changes: 27 additions & 3 deletions core/src/main/java/bisq/core/provider/fee/FeeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import bisq.core.dao.governance.param.Param;
import bisq.core.dao.governance.period.PeriodService;
import bisq.core.dao.state.DaoStateService;
import bisq.core.filter.FilterManager;

import bisq.common.UserThread;
import bisq.common.config.Config;
Expand Down Expand Up @@ -68,9 +69,31 @@ public class FeeService {
private static final long MIN_PAUSE_BETWEEN_REQUESTS_IN_MIN = 2;
private static DaoStateService daoStateService;
private static PeriodService periodService;
private static FilterManager filterManager = null;

private static Coin getFeeFromParamAsCoin(Param parm) {
return daoStateService != null && periodService != null ? daoStateService.getParamValueAsCoin(parm, periodService.getChainHeight()) : Coin.ZERO;
private static Coin getFeeFromParamAsCoin(Param param) {
// if specified, filter values take precedence
Coin fromFilter = getFilterFromParamAsCoin(param);
if (fromFilter.isGreaterThan(Coin.ZERO)) {
return fromFilter;
}
return daoStateService != null && periodService != null ? daoStateService.getParamValueAsCoin(param, periodService.getChainHeight()) : Coin.ZERO;
}

private static Coin getFilterFromParamAsCoin(Param param) {
Coin filterVal = Coin.ZERO;
if (filterManager != null) {
if (param == Param.DEFAULT_MAKER_FEE_BTC) {
filterVal = Coin.valueOf(filterManager.getFilter().getMakerFeeBtc());
} else if (param == Param.DEFAULT_TAKER_FEE_BTC) {
filterVal = Coin.valueOf(filterManager.getFilter().getTakerFeeBtc());
} else if (param == Param.DEFAULT_MAKER_FEE_BSQ) {
filterVal = Coin.valueOf(filterManager.getFilter().getMakerFeeBsq());
} else if (param == Param.DEFAULT_TAKER_FEE_BSQ) {
filterVal = Coin.valueOf(filterManager.getFilter().getTakerFeeBsq());
}
}
return filterVal;
}

public static Coin getMakerFeePerBtc(boolean currencyForFeeIsBtc) {
Expand Down Expand Up @@ -122,7 +145,8 @@ public FeeService(FeeProvider feeProvider, DaoStateService daoStateService, Peri
// API
///////////////////////////////////////////////////////////////////////////////////////////

public void onAllServicesInitialized() {
public void onAllServicesInitialized(FilterManager providedFilterManager) {
filterManager = providedFilterManager;
minFeePerVByte = Config.baseCurrencyNetwork().getDefaultMinFeePerVbyte();

requestFees();
Expand Down