-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[refactoring] FeeStrategy
implementation
#11651
[refactoring] FeeStrategy
implementation
#11651
Conversation
8c4da97
to
0418f89
Compare
} | ||
|
||
public static FeeStrategy TwentyMinutesConfirmationTargetStrategy { get; } = CreateFromConfirmationTarget(Constants.TwentyMinutesConfirmationTarget); | ||
public static FeeStrategy OneDayConfirmationTargetStrategy { get; } = CreateFromConfirmationTarget(Constants.OneDayConfirmationTarget); | ||
public static FeeStrategy SevenDaysConfirmationTargetStrategy { get; } = CreateFromConfirmationTarget(Constants.SevenDaysConfirmationTarget); | ||
|
||
public static FeeStrategy CreateFromConfirmationTarget(int confirmationTarget) => new(FeeStrategyType.Target, confirmationTarget: confirmationTarget, feeRate: null); | ||
public static FeeStrategy CreateFromConfirmationTarget(int confirmationTarget) | ||
=> new(confirmationTarget: confirmationTarget); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to easily compare with L67.
using WalletWasabi.Helpers; | ||
|
||
namespace WalletWasabi.Blockchain.TransactionBuilding; | ||
|
||
public class FeeStrategy | ||
{ | ||
public static readonly FeeRate MinimumFeeRate = new(1m); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoids allocations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Only one reference to MinimumFeeRate
. Maybe it could be private
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is that one can compare to that number if FeeRate
strategy is used. You are right that it's not used at the moment. It's a constant in a way so I think it's OK to be public.
If you feel strongly against it, please change it in a follow-up PR.
private int? _target; | ||
private FeeRate? _rate; | ||
|
||
private FeeStrategy(FeeStrategyType type, int? confirmationTarget, FeeRate? feeRate) | ||
private FeeStrategy(int confirmationTarget) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two FeeStrategyType
s, so 2 ctors is a simple approach to model that.
@@ -1,4 +1,4 @@ | |||
using System.Collections.Generic; | |||
using System.Collections.Generic; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BOM?
2a1a280
to
0796e60
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks much better!
tACK, everything seems to work just as before.
using WalletWasabi.Helpers; | ||
|
||
namespace WalletWasabi.Blockchain.TransactionBuilding; | ||
|
||
public class FeeStrategy | ||
{ | ||
public static readonly FeeRate MinimumFeeRate = new(1m); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Only one reference to MinimumFeeRate
. Maybe it could be private
?
Ha, you asked @Szpoti for review. He can certainly review the PR and I can address potential feedback in a follow-up PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
late ACK,
Looks nice, my only nit is the same for making MinimumFeeRate
private.
Simplify
FeeStrategy
implementation and remove 2 warnings in the process.Easy to review commit by commit.