Skip to content

Commit 62e1bfd

Browse files
authored
refactor: optimize some returns (#1628)
* refactor: Optimize return delete redundant judgments * changelog
1 parent d1236ba commit 62e1bfd

File tree

5 files changed

+8
-17
lines changed

5 files changed

+8
-17
lines changed

changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
* [1591](https://github.com/zeta-chain/node/pull/1591) - support lower gas limit for voting on inbound and outbound transactions
3232
* [1592](https://github.com/zeta-chain/node/issues/1592) - check inbound tracker tx hash against Tss address and some refactor on inTx observation
3333

34+
### Refactoring
35+
36+
* [1628](https://github.com/zeta-chain/node/pull/1628) optimize return and simplify code
37+
3438
## Version: v12.0.0
3539

3640
### Breaking Changes

common/chain.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ type Chains []Chain
2323

2424
// IsEqual compare two chain to see whether they represent the same chain
2525
func (chain Chain) IsEqual(c Chain) bool {
26-
if chain.ChainId == c.ChainId {
27-
return true
28-
}
29-
return false
26+
return chain.ChainId == c.ChainId
3027
}
3128

3229
func (chain Chain) IsZetaChain() bool {

rpc/namespaces/ethereum/debug/utils.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ import (
3030
func isCPUProfileConfigurationActivated(ctx *server.Context) bool {
3131
// TODO: use same constants as server/start.go
3232
// constant declared in start.go cannot be imported (cyclical dependency)
33-
const flagCPUProfile = "cpu-profile"
34-
if cpuProfile := ctx.Viper.GetString(flagCPUProfile); cpuProfile != "" {
35-
return true
36-
}
37-
return false
33+
return ctx.Viper.GetString("cpu-profile") != ""
3834
}
3935

4036
// ExpandHome expands home directory in file paths.

x/crosschain/keeper/cctx_utils.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,5 @@ func (k Keeper) GetRevertGasLimit(ctx sdk.Context, cctx types.CrossChainTx) (uin
124124

125125
func IsPending(cctx types.CrossChainTx) bool {
126126
// pending inbound is not considered a "pending" state because it has not reached consensus yet
127-
if cctx.CctxStatus.Status == types.CctxStatus_PendingOutbound || cctx.CctxStatus.Status == types.CctxStatus_PendingRevert {
128-
return true
129-
}
130-
return false
127+
return cctx.CctxStatus.Status == types.CctxStatus_PendingOutbound || cctx.CctxStatus.Status == types.CctxStatus_PendingRevert
131128
}

x/crosschain/keeper/msg_server_tss_voter.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,5 @@ func (k msgServer) CreateTSSVoter(goCtx context.Context, msg *types.MsgCreateTSS
116116
// IsAuthorizedNodeAccount checks whether a signer is authorized to sign , by checking their address against the observer mapper which contains the observer list for the chain and type
117117
func (k Keeper) IsAuthorizedNodeAccount(ctx sdk.Context, address string) bool {
118118
_, found := k.zetaObserverKeeper.GetNodeAccount(ctx, address)
119-
if found {
120-
return true
121-
}
122-
return false
119+
return found
123120
}

0 commit comments

Comments
 (0)