mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-21 14:04:12 +01:00
Random feerate and ensure sanity (#5556)
Suggested at https://github.com/btcpayserver/btcpayserver/pull/5490#issuecomment-1851066223 We can also configure this httpclient to use tor
This commit is contained in:
parent
e3863ac076
commit
541cef55b8
1 changed files with 14 additions and 1 deletions
|
@ -56,9 +56,22 @@ public class MempoolSpaceFeeProvider(
|
|||
"minimumFee" => 144,
|
||||
_ => -1
|
||||
};
|
||||
feesByBlockTarget.TryAdd(target, new FeeRate(value));
|
||||
feesByBlockTarget.TryAdd(target, new FeeRate(RandomizeByPercentage(value, 10)));
|
||||
}
|
||||
return feesByBlockTarget;
|
||||
})!;
|
||||
}
|
||||
|
||||
static decimal RandomizeByPercentage(decimal value, int percentage)
|
||||
{
|
||||
decimal range = value * percentage / 100m;
|
||||
var res = value + range * (Random.Shared.NextDouble() < 0.5 ? -1 : 1);
|
||||
|
||||
return res switch
|
||||
{
|
||||
< 1m => 1m,
|
||||
> 850 => 850,
|
||||
_ => res
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue