Skip to content

Commit 8ef378f

Browse files
committed
core/types: rename txtype set
1 parent 0c67e7c commit 8ef378f

File tree

2 files changed

+23
-27
lines changed

2 files changed

+23
-27
lines changed

core/types/transaction.go

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

55-
type txTypeBitVec [2]uint64
56-
57-
func (v *txTypeBitVec) Set(txType byte) {
58-
v[txType/64] |= 1 << (txType % 64)
59-
}
60-
61-
func (v *txTypeBitVec) Has(txType byte) bool {
62-
if txType >= byte(len(v)*64) {
63-
return false
64-
}
65-
return v[txType/64]&(1<<(txType%64)) != 0
66-
}
67-
68-
func (v *txTypeBitVec) Equals(o *txTypeBitVec) bool {
69-
return *v == *o
70-
}
71-
7255
// Transaction is an Ethereum transaction.
7356
type Transaction struct {
7457
inner TxData // Consensus contents of a transaction

core/types/transaction_signing.go

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,22 @@ 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
186-
chainID *big.Int
187-
legacy Signer
185+
txtypes txtypeSet
186+
chainID *big.Int
187+
legacy Signer
188+
}
189+
190+
type txtypeSet [2]uint64
191+
192+
func (v *txtypeSet) set(txType byte) {
193+
v[txType/64] |= 1 << (txType % 64)
194+
}
195+
196+
func (v *txtypeSet) has(txType byte) bool {
197+
if txType >= byte(len(v)*64) {
198+
return false
199+
}
200+
return v[txType/64]&(1<<(txType%64)) != 0
188201
}
189202

190203
func newModernSigner(chainID *big.Int, fork forks.Fork) Signer {
@@ -203,19 +216,19 @@ func newModernSigner(chainID *big.Int, fork forks.Fork) Signer {
203216
default:
204217
s.legacy = FrontierSigner{}
205218
}
206-
s.txTypeBitVec.Set(LegacyTxType)
219+
s.txtypes.set(LegacyTxType)
207220
// configure tx types
208221
if fork >= forks.Berlin {
209-
s.txTypeBitVec.Set(AccessListTxType)
222+
s.txtypes.set(AccessListTxType)
210223
}
211224
if fork >= forks.London {
212-
s.txTypeBitVec.Set(DynamicFeeTxType)
225+
s.txtypes.set(DynamicFeeTxType)
213226
}
214227
if fork >= forks.Cancun {
215-
s.txTypeBitVec.Set(BlobTxType)
228+
s.txtypes.set(BlobTxType)
216229
}
217230
if fork >= forks.Prague {
218-
s.txTypeBitVec.Set(SetCodeTxType)
231+
s.txtypes.set(SetCodeTxType)
219232
}
220233
return s
221234
}
@@ -226,15 +239,15 @@ func (s *modernSigner) ChainID() *big.Int {
226239

227240
func (s *modernSigner) Equal(s2 Signer) bool {
228241
other, ok := s2.(*modernSigner)
229-
return ok && s.chainID.Cmp(other.chainID) == 0 && s.txTypeBitVec.Equals(&other.txTypeBitVec) && s.legacy.Equal(other.legacy)
242+
return ok && s.chainID.Cmp(other.chainID) == 0 && s.txtypes == other.txtypes && s.legacy.Equal(other.legacy)
230243
}
231244

232245
func (s *modernSigner) Hash(tx *Transaction) common.Hash {
233246
return tx.inner.sigHash(s.chainID)
234247
}
235248

236249
func (s *modernSigner) supportsType(txtype byte) bool {
237-
return s.txTypeBitVec.Has(txtype)
250+
return s.txtypes.has(txtype)
238251
}
239252

240253
func (s *modernSigner) Sender(tx *Transaction) (common.Address, error) {

0 commit comments

Comments
 (0)