Skip to content

Commit

Permalink
fix returned shares order in case error is returned from GetLeavesByN…
Browse files Browse the repository at this point in the history
…amespace
  • Loading branch information
walldiss committed Nov 28, 2022
1 parent b56ef92 commit 53f3594
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions share/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package share
import (
"context"

"github.com/celestiaorg/celestia-node/share/ipld"
"github.com/celestiaorg/nmt/namespace"
"github.com/ipfs/go-blockservice"
"github.com/ipfs/go-cid"
format "github.com/ipfs/go-ipld-format"

"github.com/celestiaorg/celestia-node/share/ipld"
"github.com/celestiaorg/nmt/namespace"
)

// GetShare fetches and returns the data for leaf `leafIndex` of root `rootCid`.
Expand Down Expand Up @@ -59,10 +58,10 @@ func GetSharesByNamespace(
return nil, err
}

shares := make([]Share, 0, maxShares)
for _, leaf := range leaves {
shares := make([]Share, len(leaves))
for i, leaf := range leaves {
if leaf != nil {
shares = append(shares, leafToShare(leaf))
shares[i] = leafToShare(leaf)
}
}

Expand Down

0 comments on commit 53f3594

Please sign in to comment.