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

pathdb: infer stateIdent type from storage hash #15

Open
wants to merge 1 commit into
base: pbss-archive-p2
Choose a base branch
from

Conversation

weiihann
Copy link

@weiihann weiihann commented Feb 25, 2025

This PR simplifies the stateIdent struct by removing the explicit account boolean field and instead inferring account status by checking if storageHash is empty. Advantages:

  • Self-documenting data model: Derive status from the data itself rather than relying on a separate flag
  • Eliminates potential inconsistencies: Prevents situations where the boolean flag could be out of sync with the hash value
  • Cleaner API: Constructors now enforce the invariant that storage identifiers must have non-empty hashes

While comparing a 32-byte hash is slightly less performant than a boolean check, this design improves code clarity and reduces the chance of bugs where the boolean and hash values contradict each other.

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.

1 participant