Skip to content
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

Use packable BTreeSet impls #1240

Closed
wants to merge 31 commits into from
Closed

Use packable BTreeSet impls #1240

wants to merge 31 commits into from

Conversation

DaughterOfMars
Copy link

Description of change

This PR uses BTreeSets rather than boxed slices where possible when unique, ordered data is required.

Related Issues

Blocked by iotaledger/common-rs#70

@DaughterOfMars DaughterOfMars marked this pull request as ready for review September 18, 2023 13:32
Copy link
Member

@thibault-martinez thibault-martinez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conflicts

Co-authored-by: Thoralf-M <[email protected]>
Thoralf-M
Thoralf-M previously approved these changes Sep 19, 2023
@thibault-martinez
Copy link
Member

Conflicts

Thoralf-M
Thoralf-M previously approved these changes Sep 27, 2023
@thibault-martinez
Copy link
Member

Solve conflicts and I'll review/merge today

Thoralf-M
Thoralf-M previously approved these changes Sep 29, 2023
@@ -337,83 +363,86 @@ impl UnlockConditions {

/// Creates a new [`UnlockConditions`] from a vec.
pub fn from_vec(unlock_conditions: Vec<UnlockCondition>) -> Result<Self, Error> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this wouldn't error anymore on duplicates ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah currently it won't

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we somehow bring it back?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Thoralf-M
Thoralf-M previously approved these changes Oct 4, 2023
Thoralf-M
Thoralf-M previously approved these changes Oct 5, 2023
Thoralf-M
Thoralf-M previously approved these changes Oct 5, 2023
}
Self::TooManyUnlockConditions => write!(f, "too many unlock conditions"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we want max/current added?

@@ -359,7 +359,7 @@ impl DelegationOutput {

// Transition, just without full ValidationContext.
pub(crate) fn transition_inner(current_state: &Self, next_state: &Self) -> Result<(), StateTransitionError> {
if !(current_state.delegation_id.is_null() && !next_state.delegation_id().is_null()) {
if !current_state.delegation_id.is_null() | next_state.delegation_id().is_null() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice bit stuff :D lets add a |

@@ -67,6 +71,17 @@ impl Ord for Feature {
self.kind().cmp(&other.kind())
}
}
impl core::hash::Hash for Feature {
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
self.kind().hash(state);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure we want the feature hash to just be the kind? that would make 2 different SenderFeatures have the same hash

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just noticed that the Eq is also just kind. for our code it works, but what if someone gets outputs and compares it with their feature, youd just expect == to work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We started speaking about it on Slack, we should definitely continue the discussion. I really dislike this.

Copy link
Contributor

@kwek20 kwek20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well im not sure about all these hash/eq only taking the kind into consideration for external people. may be confusing. idk if we actually care about that tho.

@DaughterOfMars
Copy link
Author

I'm going to close this, as the concerns are valid and additionally I believe there is a better way to do this.

@thibault-martinez thibault-martinez deleted the feat/btree-sets branch October 16, 2023 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants