follow up

This commit is contained in:
Craig Raw
2021-10-22 11:19:26 +02:00
parent 1497b3d3bb
commit 26c177bd00
4 changed files with 14 additions and 9 deletions
@@ -139,7 +139,7 @@ public class WhirlpoolController {
tx0Previews = null;
tx0PreviewProperty.set(null);
Tx0FeeTarget tx0FeeTarget = FEE_TARGETS.get(newValue.intValue());
premixFeeRate.setText(SparrowMinerFeeSupplier.getMinimumFeeForTarget(Integer.parseInt(tx0FeeTarget.getFeeTarget().getValue())) + " sats/vB");
premixFeeRate.setText(SparrowMinerFeeSupplier.getFee(Integer.parseInt(tx0FeeTarget.getFeeTarget().getValue())) + " sats/vB");
});
premixPriority.setValue(1);
@@ -26,13 +26,18 @@ public class SparrowMinerFeeSupplier implements MinerFeeSupplier {
@Override
public int getFee(MinerFeeTarget feeTarget) {
if (AppServices.getTargetBlockFeeRates() == null) {
return FALLBACK_FEE_RATE;
}
return getMinimumFeeForTarget(Integer.parseInt(feeTarget.getValue()));
return getFee(Integer.parseInt(feeTarget.getValue()));
}
public static Integer getMinimumFeeForTarget(int targetBlocks) {
public static int getFee(int targetBlocks) {
if(AppServices.getTargetBlockFeeRates() == null) {
return FALLBACK_FEE_RATE;
}
return getMinimumFeeForTarget(targetBlocks);
}
private static Integer getMinimumFeeForTarget(int targetBlocks) {
List<Map.Entry<Integer, Double>> feeRates = new ArrayList<>(AppServices.getTargetBlockFeeRates().entrySet());
Collections.reverse(feeRates);
for(Map.Entry<Integer, Double> feeRate : feeRates) {