@@ -20,7 +20,6 @@ import (
2020 "crypto/ecdsa"
2121 "errors"
2222 "fmt"
23- "maps"
2423 "math/big"
2524
2625 "github.com/ethereum/go-ethereum/common"
@@ -183,9 +182,9 @@ type Signer interface {
183182// modernSigner is the signer implementation that handles non-legacy transaction types.
184183// For legacy transactions, it defers to one of the legacy signers (frontier, homestead, eip155).
185184type modernSigner struct {
186- txtypes map [ byte ] struct {}
187- chainID * big.Int
188- legacy Signer
185+ txTypeBitVec TxTypeBitVec
186+ chainID * big.Int
187+ legacy Signer
189188}
190189
191190func newModernSigner (chainID * big.Int , fork forks.Fork ) Signer {
@@ -194,7 +193,6 @@ func newModernSigner(chainID *big.Int, fork forks.Fork) Signer {
194193 }
195194 s := & modernSigner {
196195 chainID : chainID ,
197- txtypes : make (map [byte ]struct {}, 4 ),
198196 }
199197 // configure legacy signer
200198 switch {
@@ -205,19 +203,19 @@ func newModernSigner(chainID *big.Int, fork forks.Fork) Signer {
205203 default :
206204 s .legacy = FrontierSigner {}
207205 }
208- s .txtypes [ LegacyTxType ] = struct {}{}
206+ s .txTypeBitVec . Set ( LegacyTxType )
209207 // configure tx types
210208 if fork >= forks .Berlin {
211- s .txtypes [ AccessListTxType ] = struct {}{}
209+ s .txTypeBitVec . Set ( AccessListTxType )
212210 }
213211 if fork >= forks .London {
214- s .txtypes [ DynamicFeeTxType ] = struct {}{}
212+ s .txTypeBitVec . Set ( DynamicFeeTxType )
215213 }
216214 if fork >= forks .Cancun {
217- s .txtypes [ BlobTxType ] = struct {}{}
215+ s .txTypeBitVec . Set ( BlobTxType )
218216 }
219217 if fork >= forks .Prague {
220- s .txtypes [ SetCodeTxType ] = struct {}{}
218+ s .txTypeBitVec . Set ( SetCodeTxType )
221219 }
222220 return s
223221}
@@ -228,16 +226,15 @@ func (s *modernSigner) ChainID() *big.Int {
228226
229227func (s * modernSigner ) Equal (s2 Signer ) bool {
230228 other , ok := s2 .(* modernSigner )
231- return ok && s .chainID .Cmp (other .chainID ) == 0 && maps . Equal ( s . txtypes , other .txtypes ) && s .legacy .Equal (other .legacy )
229+ return ok && s .chainID .Cmp (other .chainID ) == 0 && s . txTypeBitVec . Equals ( & other .txTypeBitVec ) && s .legacy .Equal (other .legacy )
232230}
233231
234232func (s * modernSigner ) Hash (tx * Transaction ) common.Hash {
235233 return tx .inner .sigHash (s .chainID )
236234}
237235
238236func (s * modernSigner ) supportsType (txtype byte ) bool {
239- _ , ok := s .txtypes [txtype ]
240- return ok
237+ return s .txTypeBitVec .Has (txtype )
241238}
242239
243240func (s * modernSigner ) Sender (tx * Transaction ) (common.Address , error ) {
0 commit comments