mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-08 07:58:40 +00:00
use atomic.Pointer for authority
This commit is contained in:
parent
f5d6ea1805
commit
135d9be3d8
1 changed files with 9 additions and 8 deletions
|
|
@ -21,6 +21,7 @@ import (
|
|||
"crypto/ecdsa"
|
||||
"errors"
|
||||
"math/big"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
|
|
@ -70,13 +71,13 @@ type SetCodeTx struct {
|
|||
|
||||
// SetCodeAuthorization is an authorization from an account to deploy code at its address.
|
||||
type SetCodeAuthorization struct {
|
||||
ChainID uint256.Int `json:"chainId" gencodec:"required"`
|
||||
Address common.Address `json:"address" gencodec:"required"`
|
||||
Nonce uint64 `json:"nonce" gencodec:"required"`
|
||||
V uint8 `json:"yParity" gencodec:"required"`
|
||||
R uint256.Int `json:"r" gencodec:"required"`
|
||||
S uint256.Int `json:"s" gencodec:"required"`
|
||||
authority common.Address `json:"-"`
|
||||
ChainID uint256.Int `json:"chainId" gencodec:"required"`
|
||||
Address common.Address `json:"address" gencodec:"required"`
|
||||
Nonce uint64 `json:"nonce" gencodec:"required"`
|
||||
V uint8 `json:"yParity" gencodec:"required"`
|
||||
R uint256.Int `json:"r" gencodec:"required"`
|
||||
S uint256.Int `json:"s" gencodec:"required"`
|
||||
authority atomic.Pointer[common.Address] `json:"-"`
|
||||
}
|
||||
|
||||
// field type overrides for gencodec
|
||||
|
|
@ -136,7 +137,7 @@ func (a *SetCodeAuthorization) Authority() (common.Address, error) {
|
|||
}
|
||||
var addr common.Address
|
||||
copy(addr[:], crypto.Keccak256(pub[1:])[12:])
|
||||
a.authority = addr
|
||||
a.authority.Store(&addr)
|
||||
return addr, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue