Skip to content

Commit

Permalink
Correct proofs
Browse files Browse the repository at this point in the history
  • Loading branch information
k-karuna committed Dec 3, 2024
1 parent 2edf8aa commit a3d31b2
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions cmd/api/handler/responses/ods.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ type ODSItem struct {
}

type sequence struct {
ns share.Namespace
shareVersion uint8
startShareIndex int
data []byte
sequenceLen uint32
signer []byte
ns share.Namespace
shareVersion uint8
startShareIdx int
endShareIdx int
data []byte
sequenceLen uint32
signer []byte
}

func (ods *ODS) FindODSByNamespace(namespace string) (*ODSItem, error) {
Expand Down Expand Up @@ -172,22 +173,24 @@ func GetBlobShareIdxs(

if s.IsSequenceStart() {
sequences = append(sequences, sequence{
ns: s.Namespace(),
shareVersion: s.Version(),
startShareIndex: shareIdx,
data: s.RawData(), // todo: remove all fields except this
sequenceLen: s.SequenceLen(),
signer: share.GetSigner(s),
ns: s.Namespace(),
shareVersion: s.Version(),
startShareIdx: shareIdx,
endShareIdx: shareIdx,
data: s.RawData(),
sequenceLen: s.SequenceLen(),
signer: share.GetSigner(s),
})
} else {
if len(sequences) == 0 {
return 0, 0, errors.New("continuation share without a sequence start share")
}
prev := &sequences[len(sequences)-1]
prev.data = append(prev.data, s.RawData()...)
prev.endShareIdx = shareIdx
}
}
for i, seq := range sequences {
for _, seq := range sequences {
seq.data = seq.data[:seq.sequenceLen]
blob, err := share.NewBlob(seq.ns, seq.data, seq.shareVersion, seq.signer)
if err != nil {
Expand All @@ -198,11 +201,7 @@ func GetBlobShareIdxs(
return 0, 0, err
}
if base64.StdEncoding.EncodeToString(commitment) == b64commitment {
if i == (len(sequences))-1 { // last sequence element
return seq.startShareIndex, seq.startShareIndex, err
}

return nsStartIdx + seq.startShareIndex, nsStartIdx + sequences[i+1].startShareIndex - 1, err
return nsStartIdx + seq.startShareIdx, nsStartIdx + seq.endShareIdx + 1, err
}
}
return 0, 0, err
Expand Down

0 comments on commit a3d31b2

Please sign in to comment.