mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
use atomic.Value
This commit is contained in:
parent
2fcbfa4045
commit
8aa2362b76
1 changed files with 7 additions and 7 deletions
|
|
@ -79,8 +79,8 @@ type SetCodeAuthorization struct {
|
||||||
S uint256.Int `json:"s" gencodec:"required"`
|
S uint256.Int `json:"s" gencodec:"required"`
|
||||||
|
|
||||||
// caches
|
// caches
|
||||||
hash atomic.Pointer[common.Hash]
|
hash atomic.Value // common.Hash
|
||||||
authority atomic.Pointer[common.Address]
|
addr atomic.Value // common.Address
|
||||||
}
|
}
|
||||||
|
|
||||||
// field type overrides for gencodec
|
// field type overrides for gencodec
|
||||||
|
|
@ -112,21 +112,21 @@ func SignSetCode(prv *ecdsa.PrivateKey, auth SetCodeAuthorization) (SetCodeAutho
|
||||||
|
|
||||||
func (a *SetCodeAuthorization) sigHash() common.Hash {
|
func (a *SetCodeAuthorization) sigHash() common.Hash {
|
||||||
if hash := a.hash.Load(); hash != nil {
|
if hash := a.hash.Load(); hash != nil {
|
||||||
return *hash
|
return hash.(common.Hash)
|
||||||
}
|
}
|
||||||
hash := prefixedRlpHash(0x05, []any{
|
hash := prefixedRlpHash(0x05, []any{
|
||||||
a.ChainID,
|
a.ChainID,
|
||||||
a.Address,
|
a.Address,
|
||||||
a.Nonce,
|
a.Nonce,
|
||||||
})
|
})
|
||||||
a.hash.Store(&hash)
|
a.hash.Store(hash)
|
||||||
return hash
|
return hash
|
||||||
}
|
}
|
||||||
|
|
||||||
// Authority recovers the authorizing account of an authorization.
|
// Authority recovers the authorizing account of an authorization.
|
||||||
func (a *SetCodeAuthorization) Authority() (common.Address, error) {
|
func (a *SetCodeAuthorization) Authority() (common.Address, error) {
|
||||||
if addr := a.authority.Load(); addr != nil {
|
if addr := a.addr.Load(); addr != nil {
|
||||||
return *addr, nil
|
return addr.(common.Address), nil
|
||||||
}
|
}
|
||||||
sighash := a.sigHash()
|
sighash := a.sigHash()
|
||||||
if !crypto.ValidateSignatureValues(a.V, a.R.ToBig(), a.S.ToBig(), true) {
|
if !crypto.ValidateSignatureValues(a.V, a.R.ToBig(), a.S.ToBig(), true) {
|
||||||
|
|
@ -147,7 +147,7 @@ func (a *SetCodeAuthorization) Authority() (common.Address, error) {
|
||||||
}
|
}
|
||||||
var addr common.Address
|
var addr common.Address
|
||||||
copy(addr[:], crypto.Keccak256(pub[1:])[12:])
|
copy(addr[:], crypto.Keccak256(pub[1:])[12:])
|
||||||
a.authority.Store(&addr)
|
a.addr.Store(addr)
|
||||||
return addr, nil
|
return addr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue