[Storehouse] 003 - Payloadless ledger#8574
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
| pathFinderVersion uint8 | ||
| } | ||
|
|
||
| var _ ledger.Ledger = (*Ledger)(nil) |
There was a problem hiding this comment.
Added an interface check here, but I didn't define ledger.PayloadlessLedger interface for payloadless ledger struct yet, will add in future PR.
| // register at the given state. The returned slice is in the same order as | ||
| // `query.Keys()`. | ||
| // | ||
| // HasPaths replaces the full ledger's ValueSizes for payloadless mode, since |
There was a problem hiding this comment.
HasPaths replaces full ledger's ValueSizes method
| // | ||
| // GetSingleLeafHash replaces the full ledger's GetSingleValue for payloadless | ||
| // mode, since payload values are not retained. | ||
| func (l *PayloadlessLedger) GetSingleLeafHash(query *ledger.QuerySingleValue) (*hash.Hash, error) { |
There was a problem hiding this comment.
GetSingleLeafHash replaces the full ledger's GetSingleValue
| // | ||
| // GetLeafHashes replaces the full ledger's Get for payloadless mode, since | ||
| // payload values are not retained. | ||
| func (l *PayloadlessLedger) GetLeafHashes(query *ledger.Query) ([]*hash.Hash, error) { |
There was a problem hiding this comment.
GetLeafHashes replaces the full ledger's Get
| return nil, fmt.Errorf("could not get proofs: %w", err) | ||
| } | ||
|
|
||
| return batchProof, nil |
There was a problem hiding this comment.
The full ledger's Prove returns ledger.Proof which is a []byte slice, which is encoded trie.
However, we return a structured data *ledger.PayloadlessTrieBatchProof for now instead of []byte, because the caller will need to assemble with the payload value, and also read the leaf hash to verify the payload value. In the future, it can be optimized to []byte to reduce some decoding work.
Create Payloadless ledger that mirrors
complete.Ledgerfromledger/complete/ledger.goSee Spec