From 61c3c4a3ac5f0cb698004a1db386054337e33ea0 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 31 Aug 2020 11:28:03 +0200 Subject: [PATCH] use minimum fee rate found for higher block targets if present --- .../sparrow/net/SimpleElectrumServerRpc.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/net/SimpleElectrumServerRpc.java b/src/main/java/com/sparrowwallet/sparrow/net/SimpleElectrumServerRpc.java index 6c3d442c..03240d20 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/SimpleElectrumServerRpc.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/SimpleElectrumServerRpc.java @@ -10,10 +10,7 @@ import com.sparrowwallet.sparrow.AppController; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import static com.sparrowwallet.drongo.protocol.Transaction.DUST_RELAY_TX_FEE; @@ -216,12 +213,12 @@ public class SimpleElectrumServerRpc implements ElectrumServerRpc { result.put(targetBlock, targetBlocksFeeRateBtcKb); } catch(IllegalStateException | IllegalArgumentException e) { log.warn("Failed to retrieve fee rate for target blocks: " + targetBlock + " (" + e.getMessage() + ")"); - result.put(targetBlock, 0.0001d); + result.put(targetBlock, result.values().stream().mapToDouble(v -> v).min().orElse(0.0001d)); } catch(JsonRpcException e) { throw new ElectrumServerRpcException("Failed to retrieve fee rate for target blocks: " + targetBlock, e); } } else { - result.put(targetBlock, 0.0001d); + result.put(targetBlock, result.values().stream().mapToDouble(v -> v).min().orElse(0.0001d)); } }