From b624614ebcd1c149f58b41dbbbafbd969129b1d4 Mon Sep 17 00:00:00 2001 From: wit liu <765765346@qq.com> Date: Sun, 14 Dec 2025 15:51:21 +0800 Subject: [PATCH] core/types: use switch improve readability in function `IsVotingTransaction` (#1868) --- core/types/transaction.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/types/transaction.go b/core/types/transaction.go index d962247be3..5b76636e3d 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -511,11 +511,13 @@ func (tx *Transaction) IsVotingTransaction() (bool, *common.Address) { var end int data := tx.Data() method := hexutil.Encode(data[0:4]) - if method == common.VoteMethod || method == common.ProposeMethod || method == common.ResignMethod { + + switch method { + case common.VoteMethod, common.ProposeMethod, common.ResignMethod: end = len(data) - } else if method == common.UnvoteMethod { + case common.UnvoteMethod: end = len(data) - 32 - } else { + default: return false, nil }