feat:ephemeral header put and state for findcontent an offer - #182
feat:ephemeral header put and state for findcontent an offer#182GrapeBaBa wants to merge 1 commit into
Conversation
Signed-off-by: Chen Kai <281165273grape@gmail.com>
There was a problem hiding this comment.
Pull Request Overview
This PR introduces ephemeral header functionality for both "find content" and "offer" cases, enhancing header decoding and storage.
- Added two helper functions to decode ephemeral header payloads in types_helper.go
- Extended validation logic in validation.go to bypass ephemeral content validation
- Implemented storage support for ephemeral headers (with distinct handling for find content and offer types) and added writeOptions in beacon storage
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| types/history/types_helper.go | Added decoding functions for ephemeral header payloads |
| history/validation.go | Added bypass logic for ephemeral content validation |
| history/ephemeral_storage.go | Added Get/Put handling for ephemeral header types with batch DB updates |
| beacon/storage.go | Integrated writeOptions for beacon storage |
| } | ||
| _, err = ValidatePortalReceiptsBytes(content, header.ReceiptHash.Bytes()) | ||
| return err | ||
| case history.FindContentEphemeralType: |
There was a problem hiding this comment.
Consider adding a brief comment explaining why validation for ephemeral content is postponed, ensuring future maintainers understand that this is an intentional design decision.
| } | ||
| return payloadBytes, nil | ||
| case history.OfferEphemeralType: | ||
| return nil, fmt.Errorf("OfferEphemeralType is not supported") |
There was a problem hiding this comment.
Clarify in-code or in documentation why OfferEphemeralType is unsupported in the Get function, to avoid confusion from API consumers regarding its handling contrasted with the Put implementation.
| return fmt.Errorf("failed to commit batch: %w", err) | ||
| } | ||
| return nil | ||
| case history.OfferEphemeralType: |
There was a problem hiding this comment.
[nitpick] The OfferEphemeralType branch in the Put function includes multiple batch operations and error checks; consider refactoring this block into smaller helper functions to improve readability and long-term maintainability.
No description provided.