-
Notifications
You must be signed in to change notification settings - Fork 21
refactor(ledger): use PoolKeyHash for state #1226
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
Conversation
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
📝 WalkthroughWalkthroughThis pull request refactors the Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Areas requiring extra attention:
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
internal/test/ledger/ledger.go (1)
66-81: LGTM! Mock implementation updated correctly.The signature change and comparison logic are correct. Both
cert.OperatorandpoolKeyHashare properly compared asPoolKeyHashvalues.The comparison could be simplified since
PoolKeyHashis a fixed-size array (directly comparable):func (ls MockLedgerState) PoolCurrentState( poolKeyHash common.PoolKeyHash, ) (*common.PoolRegistrationCertificate, *uint64, error) { for _, cert := range ls.MockPoolRegistration { - if string( - common.Blake2b224(cert.Operator).Bytes(), - ) == string( - common.Blake2b224(poolKeyHash).Bytes(), - ) { + if cert.Operator == poolKeyHash { // pretend latest registration is current; no retirement support in mock c := cert return &c, nil, nil } } return nil, nil, nil }This eliminates redundant type conversions and byte comparisons.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
internal/test/ledger/ledger.go(1 hunks)ledger/alonzo/rules.go(1 hunks)ledger/babbage/rules.go(1 hunks)ledger/common/state.go(1 hunks)ledger/conway/rules.go(1 hunks)ledger/mary/rules.go(1 hunks)ledger/shelley/rules.go(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (7)
ledger/common/state.go (1)
ledger/common/certs.go (1)
PoolKeyHash(331-331)
ledger/conway/rules.go (2)
ledger/common/common.go (1)
Blake2b224(74-74)ledger/compat.go (1)
Blake2b224(26-26)
internal/test/ledger/ledger.go (2)
ledger/common/certs.go (2)
PoolKeyHash(331-331)PoolRegistrationCertificate(430-443)ledger/common/common.go (1)
Blake2b224(74-74)
ledger/mary/rules.go (1)
ledger/common/common.go (1)
Blake2b224(74-74)
ledger/babbage/rules.go (2)
ledger/common/common.go (1)
Blake2b224(74-74)ledger/compat.go (1)
Blake2b224(26-26)
ledger/shelley/rules.go (1)
ledger/common/common.go (1)
Blake2b224(74-74)
ledger/alonzo/rules.go (1)
ledger/common/common.go (1)
Blake2b224(74-74)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Analyze (go)
🔇 Additional comments (6)
ledger/common/state.go (1)
38-38: LGTM! Improved type safety with PoolKeyHash.The interface signature change from
[]bytetoPoolKeyHashenhances type safety and makes the API more explicit about what kind of data is expected.ledger/shelley/rules.go (1)
199-199: LGTM! Call site updated correctly.The call now passes
Blake2b224(tmpCert.Operator)directly as aPoolKeyHash, correctly matching the updated interface signature.ledger/conway/rules.go (1)
275-275: LGTM! Consistent with interface change.The call site correctly passes the
PoolKeyHashdirectly, aligning with the updated interface signature.ledger/mary/rules.go (1)
178-178: LGTM! Updated consistently.The change correctly passes the
PoolKeyHashdirectly toPoolCurrentState.ledger/alonzo/rules.go (1)
292-292: LGTM! Call site properly updated.The
PoolCurrentStatecall correctly passes thePoolKeyHashdirectly, matching the new interface.ledger/babbage/rules.go (1)
278-278: LGTM! Correctly updated.The change aligns with the new
PoolCurrentStatesignature by passing thePoolKeyHashdirectly.
Summary by CodeRabbit