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

refactor(net): Simplified logic for determining shared capability versions #5725

Merged
merged 4 commits into from
Dec 11, 2023

Conversation

tcoratger
Copy link
Contributor

Description

Refactored the logic to determine shared capability versions, replacing complex conditionals with a more concise approach using Option's map_or and unwrap_or. This enhances readability and maintainability while achieving the same functionality.

Comment on lines 482 to 483
if peer_capability.version >
shared_capabilities.get(&peer_capability.name).map(|v| v.version).unwrap_or(0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

there's an edge case here when the shared version == 0.

I'd like to see a test for a cap with version 0 and I think we can fix this by moving the comparison into the map and use map_or(true, )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mattsse Done, tell me what you think about this.

@mattsse mattsse added the C-debt Refactor of code section that is hard to understand or maintain label Dec 11, 2023
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm

@mattsse mattsse added this pull request to the merge queue Dec 11, 2023
Merged via the queue into paradigmxyz:main with commit 971e8d9 Dec 11, 2023
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-debt Refactor of code section that is hard to understand or maintain
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants