Skip to content

Commit 0c67e7c

Browse files
committed
refactor to use [2]uint64
1 parent 3c6d115 commit 0c67e7c

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

core/types/transaction.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,20 @@ const (
5252
SetCodeTxType = 0x04
5353
)
5454

55-
type TxTypeBitVec [(SetCodeTxType + 1 + 7) / 8]byte
55+
type txTypeBitVec [2]uint64
5656

57-
func (v *TxTypeBitVec) Set(txType byte) {
58-
if txType >= byte(len(v)*8) {
59-
panic("tx type out of range")
60-
}
61-
v[txType/8] |= 1 << (txType % 8)
57+
func (v *txTypeBitVec) Set(txType byte) {
58+
v[txType/64] |= 1 << (txType % 64)
6259
}
6360

64-
func (v *TxTypeBitVec) Has(txType byte) bool {
65-
if txType >= byte(len(v)*8) {
61+
func (v *txTypeBitVec) Has(txType byte) bool {
62+
if txType >= byte(len(v)*64) {
6663
return false
6764
}
68-
return v[txType/8]&(1<<(txType%8)) != 0
65+
return v[txType/64]&(1<<(txType%64)) != 0
6966
}
7067

71-
func (v *TxTypeBitVec) Equals(o *TxTypeBitVec) bool {
68+
func (v *txTypeBitVec) Equals(o *txTypeBitVec) bool {
7269
return *v == *o
7370
}
7471

core/types/transaction_signing.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ type Signer interface {
182182
// modernSigner is the signer implementation that handles non-legacy transaction types.
183183
// For legacy transactions, it defers to one of the legacy signers (frontier, homestead, eip155).
184184
type modernSigner struct {
185-
txTypeBitVec TxTypeBitVec
185+
txTypeBitVec txTypeBitVec
186186
chainID *big.Int
187187
legacy Signer
188188
}

0 commit comments

Comments
 (0)