-
Notifications
You must be signed in to change notification settings - Fork 267
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
Define a ParseShares
API
#723
Comments
I still think we will need to export these functions, but also expose a type ShareSet [][]byte
func ParseShares(shares [][]byte) []ShareSet then we can parse depending on namespace |
One alternative proposal that comes to mind: func ParseShares(shares [][]byte) (coretypes.Messages, coretypes.Txs, coretypes.EvidenceData, error) However this has the disadvantage that the return signature must be updated if/when we introduce more types. |
ParseShares should perform only the universal shares parsing logic, which means splitting up some set of data using only the namespace and the message start byte. Now we have some universal and purposefully ambiguous (potentially called a |
If we are wanting to parse the entire square into block data, then we already have the that being said, we can slightly refactor that function and simplify the merging logic now that we have this extra info. |
Agreed. How about? // ShareSequence represents a contiguous sequence of shares that are part of the
// same namespace and message. For compact shares, one share sequence exists per
// reserved namespace. For sparse shares, one share sequence exists per message.
type ShareSequence struct {
ID namespace.ID
Shares []Share
}
func ParseShares(shares [][]byte) []ShareSequence {
// TODO
return []ShareSequence{}
} |
docs are good btw. In the past this has just felt like fighting the type system with middleware. |
Sounds good. I opted for sequence to indicate that the order of the shares in this struct are important and I think set conveys lack of ordering.
Sorry I forgot about #721 but just commented there. I'm not strongly opinionated on keeping vs removing the |
Opted to remove the The implementation of this API should split the provided shares into sequences based on the last bit in the info byte (a.k.a the message start indicator). It is possible to rename message start indicator to sequence start indicator given this API is public and "sequence start" is more accurate given this applies to non-message shares. |
Context
celestia-node currently parses shares depending on the type of share (see here). Universal share encoding should enable us to expose one API where any type of share can be parsed. As a result, it may be possible to stop exporting
celestia-app/pkg/shares/share_merging.go
Line 125 in f67bb6b
celestia-app/pkg/shares/share_merging.go
Line 78 in f67bb6b
celestia-app/pkg/shares/share_merging.go
Line 95 in f67bb6b
The text was updated successfully, but these errors were encountered: