Skip to content

Commit

Permalink
refactor(server/v2/cometbft): update function comments (#20506)
Browse files Browse the repository at this point in the history
  • Loading branch information
tianyeyouyou authored May 31, 2024
1 parent 6967fbd commit 2e966a8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
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
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

0 comments on commit 2e966a8

Please sign in to comment.