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
Add map_anchors
for TxGraph
#1325
Conversation
Thank you for this PR! What is the purpose of commit a223c0c? |
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.
Thanks for this work. This will be a useful feature to have (talking from personal experience).
I see the doc /// The generic `A` should be a [`Anchor`] implementation. And it was not required in the enum, if it is required, we may not need an additional description on the document. This is a chore, and not about this topic, so it is separated in another commit. |
@yanganto the key The reason for this is that generic constraints stack on top of each other and will start becoming tedious if types depend on types that have generics with constraints. So when we define anything, we avoid enforcing generic constraints wherever we can. |
I think there is no |
@evanlinjin Does the test case look good from your end? If it is good, I will squash all the commit and resign it. 🙏 |
That's exactly my point. We should only put generic constraints where it's strictly necessary. |
09b7963
to
08812b8
Compare
c7ea9c7
to
425a697
Compare
b8b98a6
to
52ef8f7
Compare
There are more tx and blocks in the test case, and ready for review. |
7eeba1c
to
1360847
Compare
1360847
to
5489f90
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.
ACK 5489f90
Thanks for the review. |
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.
F: FnMut(A) -> A2, | ||
{ | ||
let mut new_graph = TxGraph::<A2>::default(); | ||
new_graph.apply_changeset(self.initial_changeset().map_anchors(f)); |
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.
⛏️ This seems weird because we allocate a giant changeset and then just apply it. I think we can just repeat the process you do in ChangeSet
.
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 multiple anchor-related fields in TxGraph
, and only one in ChangeSet
. The function caller passed in possible non-determined, so it is good to map it once here to avoid issues from a non-determined function.
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.
Huh isn't there only one acnhor related field on TxGraph
also?
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.
Huh isn't there only one acnhor related field on
TxGraph
also?
We also have anchors in TxNode
which should have 1 to 1 mapping to the anchors
field. I think the implementation right now is safer and easier to read. If in the future, there is clear performance problems we can do something more efficient.
My gripe with #1147 is that I'm assuming the Otherwise, yes, we need |
Description
Fix #1295
Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features:
Bugfixes: