Skip to content

Commit

Permalink
add better comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Manav-Aggarwal committed May 19, 2023
1 parent a97ecc5 commit 1139a4e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/shares/parse_compact_shares.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,24 @@ func parseRawData(rawData []byte) (units [][]byte, err error) {
if err != nil {
return nil, err
}
if unitLen == 0 || unitLen > uint64(len(actualData)) {
// the rest of raw data is padding
if unitLen == 0 {
return units, nil
}
// the rest of actual data contains only part of the next transaction so
// we stop parsing raw data
if unitLen > uint64(len(actualData)) {
return units, nil
}
rawData = actualData[unitLen:]
units = append(units, actualData[:unitLen])
}
}

// extractRawData returns the raw data contained in the shares. The raw data does
// not contain the namespace ID, info byte, sequence length, or reserved bytes.
// extractRawData returns the raw data representing complete transactions
// contained in the shares. The raw data does not contain the namespace, info
// byte, sequence length, or reserved bytes. Starts reading raw data based on
// the reserved bytes in the first share.
func extractRawData(shares []Share) (rawData []byte, err error) {
for i := 0; i < len(shares); i++ {
var raw []byte
Expand Down

0 comments on commit 1139a4e

Please sign in to comment.