Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(server/v2/cometbft): update function comments #20506

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions server/v2/cometbft/client/rpc/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func QueryBlocks(ctx context.Context, rpcClient CometRPC, page, limit int, query
return result, nil
}

// get block by height
// GetBlockByHeight gets block by height
func GetBlockByHeight(ctx context.Context, rpcClient CometRPC, height *int64) (*v11.Block, error) {
// header -> BlockchainInfo
// header, tx -> Block
Expand All @@ -76,6 +76,7 @@ func GetBlockByHeight(ctx context.Context, rpcClient CometRPC, height *int64) (*
return out, nil
}

// GetBlockByHash gets block by hash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider enhancing the error messages to include more details from the underlying errors.

- return nil, fmt.Errorf("unable to create response block from comet result block: %v", resBlock)
+ return nil, fmt.Errorf("unable to create response block from comet result block: %v, error: %w", resBlock, err)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
// GetBlockByHash gets block by hash
// GetBlockByHash gets block by hash
// ...
return nil, fmt.Errorf("unable to create response block from comet result block: %v, error: %w", resBlock, err)

func GetBlockByHash(ctx context.Context, rpcClient CometRPC, hashHexString string) (*v11.Block, error) {
hash, err := hex.DecodeString(hashHexString)
if err != nil {
Expand All @@ -89,8 +90,6 @@ func GetBlockByHash(ctx context.Context, rpcClient CometRPC, hashHexString strin
} else if resBlock.Block == nil {
return nil, fmt.Errorf("block not found with hash: %s", hashHexString)
}

// TODO: Also move NewResponseResultBlock somewhere around this package
out, err := NewResponseResultBlock(resBlock)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion server/v2/cometbft/client/rpc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func NewResponseResultBlock(res *coretypes.ResultBlock) (*v11.Block, error) {
return blk, nil
}

// calculate total pages in an overflow safe manner
// calcTotalPages calculates total pages in an overflow safe manner
func calcTotalPages(totalCount, limit int64) int64 {
totalPages := int64(0)
if totalCount != 0 && limit != 0 {
Expand Down
Loading