Skip to content

Commit

Permalink
removed message field in retrieve blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
chandiniv1 committed Aug 24, 2023
1 parent ce2ee0a commit 6ba5623
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
27 changes: 18 additions & 9 deletions da/avail/avail.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"io"
"net/http"
"strings"

ds "github.com/ipfs/go-datastore"

Check failure on line 10 in da/avail/avail.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

File is not `goimports`-ed with -local github.com/rollkit (goimports)
"github.com/rollkit/rollkit/da"
Expand Down Expand Up @@ -111,6 +110,7 @@ func (c *DataAvailabilityLayerClient) RetrieveBlocks(ctx context.Context, dataLa

blocks := []*types.Block{}

Loop:
blockNumber := dataLayerHeight

appDataURL := fmt.Sprintf(c.config.BaseURL+"/appdata/%d?decode=true", blockNumber)
Expand Down Expand Up @@ -139,13 +139,23 @@ func (c *DataAvailabilityLayerClient) RetrieveBlocks(ctx context.Context, dataLa
}

var appDataObject AppData
err = json.Unmarshal(responseData, &appDataObject)
if err != nil {
return da.ResultRetrieveBlocks{
BaseResult: da.BaseResult{
Code: da.StatusError,
Message: err.Error(),
},
if string(responseData) == "\"Not found\"" {

appDataObject = AppData{Block: uint32(blockNumber), Extrinsics: []string{}}

} else if string(responseData) == "\"Processing block\"" {

goto Loop

} else {
err = json.Unmarshal(responseData, &appDataObject)
if err != nil {
return da.ResultRetrieveBlocks{
BaseResult: da.BaseResult{
Code: da.StatusError,
Message: err.Error(),
},
}
}
}

Expand Down Expand Up @@ -176,7 +186,6 @@ func (c *DataAvailabilityLayerClient) RetrieveBlocks(ctx context.Context, dataLa
BaseResult: da.BaseResult{
Code: da.StatusSuccess,
DAHeight: uint64(appDataObject.Block),
Message: "block data: " + strings.Join(appDataObject.Extrinsics, " "),
},
Blocks: blocks,
}
Expand Down
2 changes: 1 addition & 1 deletion da/avail/datasubmit/submitdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func SubmitData(apiURL string, seed string, appID int, data []byte) error {
TransactionVersion: rv.TransactionVersion,
}

// Sign the transaction using Alice's default account
// Sign the transaction
err = ext.Sign(keyringPair, signOptions)
if err != nil {
return err
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ require (
golang.org/x/net v0.14.0
google.golang.org/grpc v1.56.1
google.golang.org/protobuf v1.31.0
// github.com/chandiniv1/go-substrate-rpc-client/v4 dfd1152c8eca19e7090112c105770db21149e3cf
)

require (
Expand Down

0 comments on commit 6ba5623

Please sign in to comment.