mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2025-11-05 11:56:37 +00:00
Fee rate simplification
This commit is contained in:
parent
f72e660289
commit
c5076de9a5
2 changed files with 10 additions and 12 deletions
|
|
@ -87,8 +87,8 @@ public class AppServices {
|
||||||
private static final String TOR_DEFAULT_PROXY_CIRCUIT_ID = "default";
|
private static final String TOR_DEFAULT_PROXY_CIRCUIT_ID = "default";
|
||||||
|
|
||||||
public static final List<Integer> TARGET_BLOCKS_RANGE = List.of(1, 2, 3, 4, 5, 10, 25, 50);
|
public static final List<Integer> TARGET_BLOCKS_RANGE = List.of(1, 2, 3, 4, 5, 10, 25, 50);
|
||||||
public static final List<Double> DOUBLE_FEE_RATES_RANGE = List.of(0.01D, 0.02D, 0.04D, 0.08D, 0.1D, 0.2D, 0.4D, 0.8D, 1D, 2D, 4D, 8D, 16D, 32D, 64D, 128D, 256D, 512D, 1024D, 2048D, 4096D, 8192D);
|
public static final List<Double> DOUBLE_FEE_RATES_RANGE = List.of(0.01D, 0.05D, 0.1D, 0.5, 1D, 2D, 4D, 8D, 16D, 32D, 64D, 128D, 256D, 512D, 1024D, 2048D, 4096D, 8192D);
|
||||||
public static final List<Double> FEE_RATES_RANGE = DOUBLE_FEE_RATES_RANGE.subList(0, DOUBLE_FEE_RATES_RANGE.size() - 9);
|
public static final List<Double> FEE_RATES_RANGE = DOUBLE_FEE_RATES_RANGE.subList(0, DOUBLE_FEE_RATES_RANGE.size() - 8);
|
||||||
public static final double FALLBACK_FEE_RATE = 20000d / 1000;
|
public static final double FALLBACK_FEE_RATE = 20000d / 1000;
|
||||||
public static final double TESTNET_FALLBACK_FEE_RATE = 1000d / 1000;
|
public static final double TESTNET_FALLBACK_FEE_RATE = 1000d / 1000;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,16 +63,14 @@ public class FeeRangeSlider extends Slider {
|
||||||
|
|
||||||
public double getFeeRate() {
|
public double getFeeRate() {
|
||||||
double value = getValue();
|
double value = getValue();
|
||||||
// First range: 0.01, 0.02, 0.04, 0.08 and smooth values in between
|
// First range: 0.01, 0.05, 0.1
|
||||||
if(value < 3) return 0.01 * Math.pow(2, value);
|
if(value < 1) return 0.01 + (0.05 - 0.01) * value;
|
||||||
// Transition from 0.08 to 0.1 (smoothly, using factor 1.25)
|
if(value < 2) return 0.05 + (0.1 - 0.05) * (value - 1);
|
||||||
if(value < 4) return 0.08 * Math.pow(1.25, value - 3);
|
// Second range: 0.1, 0.5, 1
|
||||||
// Second binary range: 0.1, 0.2, 0.4, 0.8 and smooth values in between
|
if(value < 3) return 0.1 + (0.5 - 0.1) * (value - 2);
|
||||||
if(value < 7) return 0.1 * Math.pow(2, value - 4);
|
if(value < 4) return 0.5 + (1.0 - 0.5) * (value - 3);
|
||||||
// Transition from 0.8 to 1.0 (smoothly, using factor 1.25)
|
// Third range: 1, 2, 4, 8, ...
|
||||||
if(value < 8) return 0.8 * Math.pow(1.25, value - 7);
|
return Math.pow(2, value - 4 + 0) * 1.0;
|
||||||
// Third binary range: 1, 2, 4, 8, ... and smooth values in between
|
|
||||||
return Math.pow(2, value - 8);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFeeRate(double feeRate) {
|
public void setFeeRate(double feeRate) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue