core/types: use switch improve readability in function IsVotingTransaction (#1868)

This commit is contained in:
wit liu 2025-12-14 15:51:21 +08:00 committed by GitHub
parent 4b7963e0ae
commit b624614ebc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
}