refactor to use [2]uint64

This commit is contained in:
cuiweixie 2025-10-24 23:57:35 +08:00
parent 3c6d115b06
commit 0c67e7cb71
No known key found for this signature in database
GPG key ID: 16DF64EE15E495A3
2 changed files with 8 additions and 11 deletions

View file

@ -52,23 +52,20 @@ const (
SetCodeTxType = 0x04
)
type TxTypeBitVec [(SetCodeTxType + 1 + 7) / 8]byte
type txTypeBitVec [2]uint64
func (v *TxTypeBitVec) Set(txType byte) {
if txType >= byte(len(v)*8) {
panic("tx type out of range")
}
v[txType/8] |= 1 << (txType % 8)
func (v *txTypeBitVec) Set(txType byte) {
v[txType/64] |= 1 << (txType % 64)
}
func (v *TxTypeBitVec) Has(txType byte) bool {
if txType >= byte(len(v)*8) {
func (v *txTypeBitVec) Has(txType byte) bool {
if txType >= byte(len(v)*64) {
return false
}
return v[txType/8]&(1<<(txType%8)) != 0
return v[txType/64]&(1<<(txType%64)) != 0
}
func (v *TxTypeBitVec) Equals(o *TxTypeBitVec) bool {
func (v *txTypeBitVec) Equals(o *txTypeBitVec) bool {
return *v == *o
}

View file

@ -182,7 +182,7 @@ type Signer interface {
// modernSigner is the signer implementation that handles non-legacy transaction types.
// For legacy transactions, it defers to one of the legacy signers (frontier, homestead, eip155).
type modernSigner struct {
txTypeBitVec TxTypeBitVec
txTypeBitVec txTypeBitVec
chainID *big.Int
legacy Signer
}