Conversation
- also a bunch of todos regarding shares computation
| "encoding/binary" | ||
| "fmt" | ||
|
|
||
| "github.com/gogo/protobuf/proto" |
There was a problem hiding this comment.
just a minor note: I would be wary of adding gogoproto further into the repo. The upstream repo will work on removing this dependency in the future.
There was a problem hiding this comment.
Ah OK, thanks! As soon as upstream will remove this, we'll upgrade too. Here, we only use it to "decorate" (gogo) proto.Messages with a MarshalDelimited method. For Tx, and (LL) Message, I have to length prefix manually anyways though.
I'll be careful to not introduce it in packages that do not already use it (types does depend on it anyways).
types/shares.go
Outdated
| func MakeShares(data []LenDelimitedMarshaler, shareSize int, nidFunc func(elem interface{}) namespace.ID) NamespacedShares { | ||
| if shareSize <= 0 { | ||
| panic("invalid shareSize") | ||
| } | ||
| shares := make([]NamespacedShare, 0) | ||
| for _, element := range data { | ||
| // TODO: implement a helper that also returns the size | ||
| // to make it possible to (cleanly) implement: | ||
| // https://github.com/lazyledger/lazyledger-specs/issues/69 | ||
| // For now, we do not squeeze multiple Tx into one share and | ||
| // hence can ignore prefixing with the starting location of the | ||
| // first start of a transaction in the share (aka SHARE_RESERVED_BYTES) | ||
| rawData, err := element.MarshalDelimited() | ||
| if err != nil { | ||
| // The (abci) app has to guarantee that it only includes messages | ||
| // that can be encoded without an error (equivalently tendermint | ||
| // must not include any Tx, Evidence etc that is unencodable) | ||
| panic(fmt.Sprintf("can not encode %v", element)) | ||
| } | ||
| nid := nidFunc(element) | ||
| if len(rawData) < shareSize { | ||
| rawShare := rawData | ||
| paddedShare := zeroPadIfNecessary(rawShare, shareSize) | ||
| share := NamespacedShare{paddedShare, nid} | ||
| shares = append(shares, share) | ||
| } else { // len(rawData) >= shareWithoutNidSize: | ||
| shares = append(shares, split(rawData, shareSize, nid)...) | ||
| } | ||
| } | ||
| return shares | ||
| } |
There was a problem hiding this comment.
@adlerjohn I'll leave away prefixing with the reserved share bytes and initially treat Tx, Evidence etc no different than (LL) Messages in the sense that one share will contain one Tx.
There was a problem hiding this comment.
Meaning, I'm intentionally skipping the * in https://github.com/lazyledger/lazyledger-specs/blob/master/specs/figures/share.svg as there is always only one Tx per share in the first version.
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Description
Closes: #XXX