mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-08 07:58:40 +00:00
all: expose DeriveAuthorities publicly, use in other Message call sites
This commit is contained in:
parent
cc65a4ad32
commit
350978a0a6
4 changed files with 9 additions and 7 deletions
|
|
@ -523,7 +523,7 @@ func (tx *Transaction) SetCodeAuthorities() []*common.Address {
|
|||
if cache := tx.auths.Load(); cache != nil {
|
||||
return *cache
|
||||
}
|
||||
cache := setcodetx.deriveAuthorities()
|
||||
cache := (authCache)(DeriveAuthorities(setcodetx.AuthList))
|
||||
tx.auths.Store(&cache)
|
||||
return cache
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,14 +66,16 @@ type SetCodeTx struct {
|
|||
S *uint256.Int
|
||||
}
|
||||
|
||||
// authCache is an internal helper type used in the Transaction object to cache
|
||||
// authorizations.
|
||||
type authCache []*common.Address
|
||||
|
||||
// deriveAuthorities returns a list of recovered authorization signers. The
|
||||
// DeriveAuthorities returns a list of recovered authorization signers. The
|
||||
// length is always equal to the number of authorizations. Any authorities that
|
||||
// fail to recover are set as nil in the list.
|
||||
func (tx *SetCodeTx) deriveAuthorities() authCache {
|
||||
auths := make([]*common.Address, 0, len(tx.AuthList))
|
||||
for _, auth := range tx.AuthList {
|
||||
func DeriveAuthorities(authList []SetCodeAuthorization) []*common.Address {
|
||||
auths := make([]*common.Address, 0, len(authList))
|
||||
for _, auth := range authList {
|
||||
if addr, err := auth.Authority(); err == nil {
|
||||
auths = append(auths, &addr)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -490,7 +490,7 @@ func (args *TransactionArgs) ToMessage(baseFee *big.Int, skipNonceCheck bool) *c
|
|||
BlobGasFeeCap: (*big.Int)(args.BlobFeeCap),
|
||||
BlobHashes: args.BlobHashes,
|
||||
SetCodeAuthorizations: args.AuthorizationList,
|
||||
AuthorityCache: types.ToAuthorityCache(args.AuthorizationList),
|
||||
Authorities: types.DeriveAuthorities(args.AuthorizationList),
|
||||
SkipNonceChecks: skipNonceCheck,
|
||||
SkipTransactionChecks: true,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -477,7 +477,7 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *big.Int) (*core.Mess
|
|||
BlobHashes: tx.BlobVersionedHashes,
|
||||
BlobGasFeeCap: tx.BlobGasFeeCap,
|
||||
SetCodeAuthorizations: authList,
|
||||
AuthorityCache: types.ToAuthorityCache(authList),
|
||||
Authorities: types.DeriveAuthorities(authList),
|
||||
}
|
||||
return msg, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue