Skip to content

Commit 0a1d8e2

Browse files
committed
refactor: use a more modern writing style to simplify code
Signed-off-by: deepdring <deepdrink@icloud.com>
1 parent cde48ef commit 0a1d8e2

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

app/app.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"io"
1010
"io/fs"
11+
"maps"
1112
"math"
1213
"net/http"
1314
"os"
@@ -1343,9 +1344,7 @@ func RegisterSwaggerAPI(_ client.Context, rtr *mux.Router) {
13431344
// GetMaccPerms returns a copy of the module account permissions
13441345
func GetMaccPerms() map[string][]string {
13451346
dupMaccPerms := make(map[string][]string)
1346-
for k, v := range maccPerms {
1347-
dupMaccPerms[k] = v
1348-
}
1347+
maps.Copy(dupMaccPerms, maccPerms)
13491348
return dupMaccPerms
13501349
}
13511350

x/cronos/rpc/api.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,9 @@ 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 {
282+
contextHeight := max(blockNumber-1,
284283
// 0 is a special value in `ContextWithHeight`
285-
contextHeight = 1
286-
}
284+
1)
287285
rsp, err := api.cronosQueryClient.ReplayBlock(rpctypes.ContextWithHeight(contextHeight), req)
288286
if err != nil {
289287
return nil, err

0 commit comments

Comments
 (0)