Skip to content

Commit

Permalink
added BlockDataGet (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
vvuwei authored Oct 31, 2023
1 parent 63e3afb commit 08d1918
Show file tree
Hide file tree
Showing 24 changed files with 61 additions and 62 deletions.
3 changes: 0 additions & 3 deletions internal/storage/mock/address.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions internal/storage/mock/balance.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions internal/storage/mock/block.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions internal/storage/mock/block_stats.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions internal/storage/mock/constant.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions internal/storage/mock/denom_metadata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions internal/storage/mock/event.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions internal/storage/mock/generic.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions internal/storage/mock/message.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions internal/storage/mock/namespace.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions internal/storage/mock/state.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions internal/storage/mock/stats.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions internal/storage/mock/tx.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions internal/storage/mock/validator.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions internal/storage/types/event_type_enum.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions internal/storage/types/module_enum.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions internal/storage/types/msg_address_type_enum.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions internal/storage/types/msg_type_enum.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions internal/storage/types/status_enum.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pkg/indexer/receiver/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ func (s *ModuleTestSuite) TestModule_SyncReadsBlocks() {

for i := types.Level(1); i <= blockCount; i++ {
s.api.EXPECT().
BlockData(gomock.Any(), i).
// BlockData(gomock.Any(), i).
BlockDataGet(gomock.Any(), i).
Return(types.BlockData{
ResultBlock: getResultBlock(i),
ResultBlockResults: getResultBlockResults(i),
Expand Down
2 changes: 1 addition & 1 deletion pkg/indexer/receiver/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (r *Module) worker(ctx context.Context, level types.Level) {
default:
}

block, err := r.api.BlockData(ctx, level)
block, err := r.api.BlockDataGet(ctx, level)
if err != nil {
if errors.Is(err, context.Canceled) {
return
Expand Down
1 change: 1 addition & 0 deletions pkg/node/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Api interface {
BlockResults(ctx context.Context, level pkgTypes.Level) (pkgTypes.ResultBlockResults, error)
Genesis(ctx context.Context) (types.Genesis, error)
BlockData(ctx context.Context, level pkgTypes.Level) (pkgTypes.BlockData, error)
BlockDataGet(ctx context.Context, level pkgTypes.Level) (pkgTypes.BlockData, error)
}

//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
Expand Down
42 changes: 39 additions & 3 deletions pkg/node/mock/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions pkg/node/rpc/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,21 @@ func (api *API) BlockData(ctx context.Context, level pkgTypes.Level) (pkgTypes.B
blockData.ResultBlockResults = results.Result
return blockData, nil
}

func (api *API) BlockDataGet(ctx context.Context, level pkgTypes.Level) (pkgTypes.BlockData, error) {
var blockData pkgTypes.BlockData

block, err := api.Block(ctx, level)
if err != nil {
return blockData, errors.Wrapf(types.ErrRequest, "request error: %s", err.Error())
}

results, err := api.BlockResults(ctx, level)
if err != nil {
return blockData, errors.Wrapf(types.ErrRequest, "request error: %s", err.Error())
}

blockData.ResultBlock = block
blockData.ResultBlockResults = results
return blockData, nil
}

0 comments on commit 08d1918

Please sign in to comment.