Skip to content

Commit ad5f7a9

Browse files
committed
refactor: use the built-in max/min to simplify the code
Signed-off-by: jingchanglu <[email protected]>
1 parent 7867ace commit ad5f7a9

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

x/cronos/rpc/api.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,8 @@ func (api *CronosAPI) ReplayBlock(blockNrOrHash rpctypes.BlockNumberOrHash, post
279279
}
280280

281281
// minus one to get the context of block beginning
282-
contextHeight := blockNumber - 1
283-
if contextHeight < 1 {
284-
// 0 is a special value in `ContextWithHeight`
285-
contextHeight = 1
286-
}
282+
// 0 is a special value in `ContextWithHeight`
283+
contextHeight := max(blockNumber-1, 1)
287284
rsp, err := api.cronosQueryClient.ReplayBlock(rpctypes.ContextWithHeight(contextHeight), req)
288285
if err != nil {
289286
return nil, err

0 commit comments

Comments
 (0)