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

Encapsulate validate_header_regarding_parent inside SealedHeader #6404

Merged
merged 5 commits into from
Feb 6, 2024

Conversation

tcoratger
Copy link
Contributor

@tcoratger tcoratger commented Feb 5, 2024

Changes Made

This pull request encapsulates the validate_header_regarding_parent function within the SealedHeader struct. The encapsulation is done to improve code organization and enhance encapsulation of header-related validation logic.

  • Errors from validate_header_regarding_parent are mapped inside a SealedHeaderError enum.
  • An error field SealedHeaderError is introduced inside ConsensusError enum, transparently wrapping SealedHeaderError
  • All old unused ConsensusError error fields that are wrapped inside SealedHeaderError are removed from ConsensusError enum to clean up and better organize errors there.

Should close #6193.

Motivation

Encapsulating validate_header_regarding_parent within SealedHeader promotes a cleaner code structure by keeping related functionality within the same module. This encapsulation enhances the readability and maintainability of the codebase.

Impact

This change does not introduce any functional changes but improves the organization of the code. Existing functionality remains unchanged, and this encapsulation serves as a step towards better code organization.

@tcoratger tcoratger requested a review from gakonst as a code owner February 5, 2024 14:38
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.

I like this a lot, this is much better than having standalone functions.

some naming nits otherwise lgtm

pending @Rjected

@mattsse mattsse added the C-debt A clean up/refactor of existing code label Feb 6, 2024
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, pending @Rjected

Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

LGTM, I like that this puts the header validation errors in a new type

@mattsse mattsse added this pull request to the merge queue Feb 6, 2024
Merged via the queue into paradigmxyz:main with commit 2c119b8 Feb 6, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-debt A clean up/refactor of existing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Encapsulate validate_header_regarding_parent inside Header
3 participants