use minimum fee rate found for higher block targets if present

This commit is contained in:
Craig Raw 2020-08-31 11:28:03 +02:00
parent 5d6bb5e4f9
commit 61c3c4a3ac

View file

@ -10,10 +10,7 @@ import com.sparrowwallet.sparrow.AppController;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.LinkedHashMap; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.sparrowwallet.drongo.protocol.Transaction.DUST_RELAY_TX_FEE; import static com.sparrowwallet.drongo.protocol.Transaction.DUST_RELAY_TX_FEE;
@ -216,12 +213,12 @@ public class SimpleElectrumServerRpc implements ElectrumServerRpc {
result.put(targetBlock, targetBlocksFeeRateBtcKb); result.put(targetBlock, targetBlocksFeeRateBtcKb);
} catch(IllegalStateException | IllegalArgumentException e) { } catch(IllegalStateException | IllegalArgumentException e) {
log.warn("Failed to retrieve fee rate for target blocks: " + targetBlock + " (" + e.getMessage() + ")"); 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) { } catch(JsonRpcException e) {
throw new ElectrumServerRpcException("Failed to retrieve fee rate for target blocks: " + targetBlock, e); throw new ElectrumServerRpcException("Failed to retrieve fee rate for target blocks: " + targetBlock, e);
} }
} else { } else {
result.put(targetBlock, 0.0001d); result.put(targetBlock, result.values().stream().mapToDouble(v -> v).min().orElse(0.0001d));
} }
} }