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 {
|
if cache := tx.auths.Load(); cache != nil {
|
||||||
return *cache
|
return *cache
|
||||||
}
|
}
|
||||||
cache := setcodetx.deriveAuthorities()
|
cache := (authCache)(DeriveAuthorities(setcodetx.AuthList))
|
||||||
tx.auths.Store(&cache)
|
tx.auths.Store(&cache)
|
||||||
return cache
|
return cache
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,14 +66,16 @@ type SetCodeTx struct {
|
||||||
S *uint256.Int
|
S *uint256.Int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// authCache is an internal helper type used in the Transaction object to cache
|
||||||
|
// authorizations.
|
||||||
type authCache []*common.Address
|
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
|
// length is always equal to the number of authorizations. Any authorities that
|
||||||
// fail to recover are set as nil in the list.
|
// fail to recover are set as nil in the list.
|
||||||
func (tx *SetCodeTx) deriveAuthorities() authCache {
|
func DeriveAuthorities(authList []SetCodeAuthorization) []*common.Address {
|
||||||
auths := make([]*common.Address, 0, len(tx.AuthList))
|
auths := make([]*common.Address, 0, len(authList))
|
||||||
for _, auth := range tx.AuthList {
|
for _, auth := range authList {
|
||||||
if addr, err := auth.Authority(); err == nil {
|
if addr, err := auth.Authority(); err == nil {
|
||||||
auths = append(auths, &addr)
|
auths = append(auths, &addr)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -490,7 +490,7 @@ func (args *TransactionArgs) ToMessage(baseFee *big.Int, skipNonceCheck bool) *c
|
||||||
BlobGasFeeCap: (*big.Int)(args.BlobFeeCap),
|
BlobGasFeeCap: (*big.Int)(args.BlobFeeCap),
|
||||||
BlobHashes: args.BlobHashes,
|
BlobHashes: args.BlobHashes,
|
||||||
SetCodeAuthorizations: args.AuthorizationList,
|
SetCodeAuthorizations: args.AuthorizationList,
|
||||||
AuthorityCache: types.ToAuthorityCache(args.AuthorizationList),
|
Authorities: types.DeriveAuthorities(args.AuthorizationList),
|
||||||
SkipNonceChecks: skipNonceCheck,
|
SkipNonceChecks: skipNonceCheck,
|
||||||
SkipTransactionChecks: true,
|
SkipTransactionChecks: true,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -477,7 +477,7 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *big.Int) (*core.Mess
|
||||||
BlobHashes: tx.BlobVersionedHashes,
|
BlobHashes: tx.BlobVersionedHashes,
|
||||||
BlobGasFeeCap: tx.BlobGasFeeCap,
|
BlobGasFeeCap: tx.BlobGasFeeCap,
|
||||||
SetCodeAuthorizations: authList,
|
SetCodeAuthorizations: authList,
|
||||||
AuthorityCache: types.ToAuthorityCache(authList),
|
Authorities: types.DeriveAuthorities(authList),
|
||||||
}
|
}
|
||||||
return msg, nil
|
return msg, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue