Skip to content

Commit

Permalink
Refactor: blob proofs querying replaced by NewShareInclusionProofFrom…
Browse files Browse the repository at this point in the history
…EDS from celestia-app
  • Loading branch information
k-karuna committed Dec 4, 2024
1 parent 492c4e4 commit 09fe2ea
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions cmd/api/handler/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"encoding/base64"
"encoding/hex"
"github.com/celestiaorg/celestia-app/v3/pkg/appconsts"
"github.com/celestiaorg/celestia-app/v3/pkg/da"
"github.com/celestiaorg/go-square/v2/share"
"net/http"
"time"

Expand All @@ -19,6 +21,7 @@ import (
"github.com/celenium-io/celestia-indexer/internal/storage"
testsuite "github.com/celenium-io/celestia-indexer/internal/test_suite"
"github.com/celenium-io/celestia-indexer/pkg/node"
"github.com/celestiaorg/celestia-app/v3/pkg/proof"
"github.com/labstack/echo/v4"
)

Expand Down Expand Up @@ -776,10 +779,30 @@ func (handler *NamespaceHandler) BlobProofs(c echo.Context) error {
if err != nil {
return internalServerError(c, err)
}
shareRange := share.Range{
Start: startBlobIndex,
End: endBlobIndex,
}

eds, err := da.ExtendShares(share.ToBytes(dataSquare))
if err != nil {
return internalServerError(c, err)
}

namespaceBytes, err := base64.StdEncoding.DecodeString(req.Hash)
if err != nil {
return internalServerError(c, err)
}

proofs, err := handler.node.BlobProofs(c.Request().Context(), req.Height, startBlobIndex, endBlobIndex)
namespace, err := share.NewNamespaceFromBytes(namespaceBytes)
if err != nil {
return internalServerError(c, err)
}

proofs, err := proof.NewShareInclusionProofFromEDS(eds, namespace, shareRange)
if err != nil {
return handleError(c, err, handler.namespace)
}
return c.JSON(http.StatusOK, proofs)

return c.JSON(http.StatusOK, proofs.ShareProofs)
}

0 comments on commit 09fe2ea

Please sign in to comment.