Skip to content

Commit

Permalink
fix: update nmt and fix blob proof serialization (#55)
Browse files Browse the repository at this point in the history
Upgrades to match node [v0.11.0-rc14 - Cache
Fixes](https://github.com/celestiaorg/celestia-node/releases/tag/v0.11.0-rc14)

Related: celestiaorg/celestia-node#2728

Co-authored-by: nashqueue <99758629+nashqueue@users.noreply.github.com>
  • Loading branch information
distractedm1nd and nashqueue authored Oct 17, 2023
1 parent b6ae65b commit fe2f88b
Showing 1 changed file with 0 additions and 36 deletions.
36 changes: 0 additions & 36 deletions types/blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,42 +43,6 @@ type Proof []*nmt.Proof

func (p Proof) Len() int { return len(p) }

type jsonProof struct {
Start int `json:"start"`
End int `json:"end"`
Nodes [][]byte `json:"nodes"`
}

func (p *Proof) MarshalJSON() ([]byte, error) {
proofs := make([]jsonProof, 0, p.Len())
for _, pp := range *p {
proofs = append(proofs, jsonProof{
Start: pp.Start(),
End: pp.End(),
Nodes: pp.Nodes(),
})
}

return json.Marshal(proofs)
}

func (p *Proof) UnmarshalJSON(data []byte) error {
var proofs []jsonProof
err := json.Unmarshal(data, &proofs)
if err != nil {
return err
}

nmtProofs := make([]*nmt.Proof, len(proofs))
for i, jProof := range proofs {
nmtProof := nmt.NewInclusionProof(jProof.Start, jProof.End, jProof.Nodes, NMTIgnoreMaxNamespace)
nmtProofs[i] = &nmtProof
}

*p = nmtProofs
return nil
}

type jsonBlob struct {
Namespace share.Namespace `json:"namespace"`
Data []byte `json:"data"`
Expand Down

0 comments on commit fe2f88b

Please sign in to comment.