Skip to content

Commit

Permalink
add mempool fees to the getAllMarketPrices endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacxx committed Jun 7, 2021
1 parent 806253b commit e901e39
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 2 additions & 0 deletions common/src/main/java/bisq/common/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ public class Config {
public static final String API_PORT = "apiPort";
public static final String PREVENT_PERIODIC_SHUTDOWN_AT_SEED_NODE = "preventPeriodicShutdownAtSeedNode";
public static final String REPUBLISH_MAILBOX_ENTRIES = "republishMailboxEntries";
public static final String LEGACY_FEE_DATAMAP = "dataMap";
public static final String BTC_TX_FEE = "btcTxFee";
public static final String BTC_MIN_TX_FEE = "btcMinTxFee";
public static final String BTC_FEES_TS = "bitcoinFeesTs";
public static final String BTC_FEE_INFO = "bitcoinFeeInfo";
public static final String BYPASS_MEMPOOL_VALIDATION = "bypassMempoolValidation";

// Default values for certain options
Expand Down
4 changes: 2 additions & 2 deletions pricenode/src/main/java/bisq/price/mining/FeeRateService.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* High-level mining {@link FeeRate} operations.
*/
@Service
class FeeRateService {
public class FeeRateService {

private final List<FeeRateProvider> providers;
protected final Logger log = LoggerFactory.getLogger(this.getClass());
Expand Down Expand Up @@ -101,7 +101,7 @@ public Map<String, Object> getFees() {
// Build response
return new HashMap<>() {{
putAll(metadata);
put("dataMap", allFeeRates);
put(Config.LEGACY_FEE_DATAMAP, allFeeRates);
}};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
package bisq.price.spot;

import bisq.price.PriceController;
import bisq.price.mining.FeeRateService;

import bisq.common.config.Config;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -28,13 +31,28 @@
class ExchangeRateController extends PriceController {

private final ExchangeRateService exchangeRateService;
private final FeeRateService feeRateService;

public ExchangeRateController(ExchangeRateService exchangeRateService) {
public ExchangeRateController(ExchangeRateService exchangeRateService, FeeRateService feeRateService) {
this.exchangeRateService = exchangeRateService;
this.feeRateService = feeRateService;
}

@GetMapping(path = "/getAllMarketPrices")
public Map<String, Object> getAllMarketPrices() {
return exchangeRateService.getAllMarketPrices();
Map<String, Object> retVal = exchangeRateService.getAllMarketPrices();

// add the fee info to results
feeRateService.getFees().forEach((key, value) -> {
retVal.put(translateFieldName(key), value);
});

return retVal;
}

static String translateFieldName(String name) {
if (name.equals(Config.LEGACY_FEE_DATAMAP))
name = Config.BTC_FEE_INFO; // name changed for clarity
return name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private void doSanityChecksForRetrievedData(Map<String, Object> retrievedData, l
// providers), we always expect a non-zero timestamp
assertNotEquals(0L, retrievedData.get(Config.BTC_FEES_TS));

Map<String, String> retrievedDataMap = (Map<String, String>) retrievedData.get("dataMap");
Map<String, String> retrievedDataMap = (Map<String, String>) retrievedData.get(Config.LEGACY_FEE_DATAMAP);
assertEquals(2, retrievedDataMap.size());
assertEquals(expectedFeeRate, retrievedDataMap.get(Config.BTC_TX_FEE));
}
Expand Down

0 comments on commit e901e39

Please sign in to comment.