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

chore: check blockhash/txhash length whether it is 64 #699

Merged
merged 12 commits into from
Oct 12, 2022
Prev Previous commit
Next Next commit
chore: check blockhash length whether it is 64
tkxkd0159 committed Oct 11, 2022

Verified

This commit was signed with the committer’s verified signature. The key has been revoked.
richardcase Richard Case
commit e544408569b7dcae3babadcc1e9fe4ea25b460c6
7 changes: 7 additions & 0 deletions client/grpc/tmservice/service.go
Original file line number Diff line number Diff line change
@@ -88,6 +88,13 @@ func (s queryServer) GetBlockByHeight(ctx context.Context, req *GetBlockByHeight

// GetBlockByHash implements ServiceServer.GetBlockByHash
func (s queryServer) GetBlockByHash(_ context.Context, req *GetBlockByHashRequest) (*GetBlockByHashResponse, error) {
if n := len(req.Hash); n != 64 {
if n == 0 {
return nil, status.Error(codes.InvalidArgument, "block hash cannot be empty")
}
return nil, status.Error(codes.InvalidArgument, "The length of blcok hash must be 64")
}

res, err := getBlockByHash(s.clientCtx, req.Hash)
if err != nil {
return nil, err