core/types: use switch improve readability (#1867)

This commit is contained in:
wit liu 2025-12-12 19:26:25 +08:00 committed by GitHub
parent 07c6262d42
commit 4b7963e0ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -41,13 +41,6 @@ var (
errInvalidYParity = errors.New("'yParity' field must be 0 or 1")
errVYParityMismatch = errors.New("'v' and 'yParity' fields do not match")
errVYParityMissing = errors.New("missing 'yParity' or 'v' field in transaction")
skipNonceDestinationAddress = map[common.Address]bool{
common.XDCXAddrBinary: true,
common.TradingStateAddrBinary: true,
common.XDCXLendingAddressBinary: true,
common.XDCXLendingFinalizedTradeAddressBinary: true,
}
)
// Transaction types.
@ -482,7 +475,19 @@ func (tx *Transaction) IsLendingFinalizedTradeTransaction() bool {
func (tx *Transaction) IsSkipNonceTransaction() bool {
to := tx.To()
return to != nil && skipNonceDestinationAddress[*to]
if to == nil {
return false
}
switch *to {
case common.XDCXAddrBinary,
common.TradingStateAddrBinary,
common.XDCXLendingAddressBinary,
common.XDCXLendingFinalizedTradeAddressBinary:
return true
default:
return false
}
}
func (tx *Transaction) IsSigningTransaction() bool {