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
Refactor WhiteList #9963
Refactor WhiteList #9963
Conversation
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.
LGTM
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.
tACK
if (!string.IsNullOrEmpty(WhitelistFilePath)) | ||
{ | ||
var toFile = GetInnocents().Select(innocent => innocent.ToString()); | ||
File.WriteAllLines(WhitelistFilePath, toFile); | ||
var toFile = Innocents.Values.Select(innocent => innocent.ToString()); |
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.
One thing to be aware here Innoncents
being ConcurrentDictionary
means that Innoncents
can change at any point even during iteration (in WriteToFileIfChangedAsync
or RemoveAllExpired
).
Here it looks OK because it looks like Innocents.Values
represents a moment in time snapshot of values.
Still I find that pretty hard to reason about. Having a simple lock + a simple Dictionary<OutPoint, Innocent>
is imho much easier to understand and verify correctness.
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.
pretty hard to reason about
Less code.
much easier to understand and verify correctness.
I did not touch that part here it was using ConcurrentDictionary
before the PR for this reason it is out of scope here. Do you have a specific use case that can be problematic?
It would be nice to rename |
public void Add(Alice alice)
=> Save(new Innocent(alice.Coin.Outpoint, DateTimeOffset.UtcNow)); seems to be unused. |
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.
LGTM
WhiteList
will be able to check and release coins one by one - right at the time when requested. This is required for further work with CoinVerifier.