Use static arrays for test net
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
@@ -258,35 +258,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
base.OnNavigatedTo(inStack, disposables);
}
- private void UpdateFeeEstimates(Dictionary<int, int> feeEstimates)
- {
- const int Divisions = 256;
- string[] xAxisLabels;
- double[] xAxisValues;
- double[] yAxisValues;
-
- if (_owner.Wallet.Network != Network.TestNet)
- {
- xAxisLabels = feeEstimates.Select(x => x.Key)
- .Select(x => FeeTargetTimeConverter.Convert(x, "m", "h", "h", "d", "d"))
- .Reverse()
- .ToArray();
-
- var xs = feeEstimates.Select(x => (double)x.Key).ToArray();
- var ys = feeEstimates.Select(x => (double)x.Value).ToArray();
-#if true
- // GetSmoothValues(xs, ys, out var ts, out var xts);
- GetSmoothValuesSubdivide(xs, ys, Divisions, out var ts, out var xts);
- xAxisValues = ts.ToArray();
- yAxisValues = xts.ToArray();
-#else
- xAxisValues = xs.Reverse().ToArray();
- yAxisValues = ys.Reverse().ToArray();
-#endif
- }
- else
- {
- xAxisLabels = new string[]
+ private static readonly string[] TestNetXAxisLabels =
{
"1w",
"3d",
@@ -300,7 +272,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
"fastest"
};
- var xs = new double[]
+ private static readonly double[] TestNetXAxisValues =
{
1,
2,
@@ -314,7 +286,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
1008
};
- var ys = new double[]
+ private static readonly double[] TestNetYAxisValues =
{
185,
123,
@@ -328,6 +300,22 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
4
};
+ private void UpdateFeeEstimates(Dictionary<int, int> feeEstimates)
+ {
+ const int Divisions = 256;
+ string[] xAxisLabels;
+ double[] xAxisValues;
+ double[] yAxisValues;
+
+ if (_owner.Wallet.Network != Network.TestNet)
+ {
+ var labels = feeEstimates.Select(x => x.Key)
+ .Select(x => FeeTargetTimeConverter.Convert(x, "m", "h", "h", "d", "d"))
+ .Reverse()
+ .ToArray();
+
+ var xs = feeEstimates.Select(x => (double)x.Key).ToArray();
+ var ys = feeEstimates.Select(x => (double)x.Value).ToArray();
#if true
// GetSmoothValues(xs, ys, out var ts, out var xts);
GetSmoothValuesSubdivide(xs, ys, Divisions, out var ts, out var xts);
@@ -337,6 +325,20 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
xAxisValues = xs.Reverse().ToArray();
yAxisValues = ys.Reverse().ToArray();
#endif
+ xAxisLabels = labels;
+ }
+ else
+ {
+#if true
+ // GetSmoothValues(xs, ys, out var ts, out var xts);
+ GetSmoothValuesSubdivide(TestNetXAxisValues, TestNetYAxisValues, Divisions, out var ts, out var xts);
+ xAxisValues = ts.ToArray();
+ yAxisValues = xts.ToArray();
+#else
+ xAxisValues = xs.Reverse().ToArray();
+ yAxisValues = ys.Reverse().ToArray();
+#endif
+ xAxisLabels = TestNetXAxisLabels;
}
XAxisLabels = xAxisLabels;
@@ -344,26 +346,6 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
YAxisValues = yAxisValues;
}
- private void GetSmoothValues(double[] xs, double[] ys, out List<double> ts, out List<double> xts)
- {
- var min = xs.Min();
- var max = xs.Max();
- var spline = CubicSpline.InterpolatePchipSorted(xs, ys);
-
- ts = new List<double>();
- xts = new List<double>();
-
- for (double t = min; t <= max; t += 1)
- {
- var xt = spline.Interpolate(t);
- ts.Add(t);
- xts.Add(xt);
- }
-
- ts.Reverse();
- xts.Reverse();
- }
-
private void GetSmoothValuesSubdivide(double[] xs, double[] ys, int divisions, out List<double> ts, out List<double> xts)
{
ts = new List<double>();
@@ -411,6 +393,26 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
xts.Reverse();
}
+ private void GetSmoothValues(double[] xs, double[] ys, out List<double> ts, out List<double> xts)
+ {
+ var min = xs.Min();
+ var max = xs.Max();
+ var spline = CubicSpline.InterpolatePchipSorted(xs, ys);
+
+ ts = new List<double>();
+ xts = new List<double>();
+
+ for (double t = min; t <= max; t += 1)
+ {
+ var xt = spline.Interpolate(t);
+ ts.Add(t);
+ xts.Add(xt);
+ }
+
+ ts.Reverse();
+ xts.Reverse();
+ }
+
private decimal GetYAxisValueFromXAxisCurrentValue(double xValue)
{
if (_xAxisValues is { } && _yAxisValues is { })

Use static arrays for test net