Skip to content

Commit

Permalink
Rename to Clone()
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronbuchwald committed Aug 11, 2021
1 parent f175634 commit b60f145
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions common/types.go
Expand Up @@ -339,9 +339,8 @@ func (a Address) Value() (driver.Value, error) {
return a[:], nil
}

// CopyPointer returns a new pointer to a copy of the address or nil
// if [a] is nil.
func (a *Address) CopyPointer() *Address {
// Clone returns a pointer to a copy of [a] (or nil if [a] is nil)
func (a *Address) Clone() *Address {
if a == nil {
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions common/types_test.go
Expand Up @@ -460,7 +460,7 @@ func TestCopyAddress(t *testing.T) {
t.Fatalf("Expected original address bytes to be unmodified")
}
addrPtr := &addr
cpy := addrPtr.CopyPointer()
cpy := addrPtr.Clone()
cpy.SetBytes([]byte("deadbeef"))
if !bytes.Equal(addr.Bytes(), addrBytes) {
t.Fatal("Expected original address bytes to be unmodified")
Expand All @@ -470,7 +470,7 @@ func TestCopyAddress(t *testing.T) {
}

var nilAddr *Address
copiedNilAddr := nilAddr.CopyPointer()
copiedNilAddr := nilAddr.Clone()
if copiedNilAddr != nil {
t.Fatalf("Expected copied nil address to be nil, but got %s", copiedNilAddr)
}
Expand Down
2 changes: 1 addition & 1 deletion core/types/access_list_tx.go
Expand Up @@ -59,7 +59,7 @@ type AccessListTx struct {
func (tx *AccessListTx) copy() TxData {
cpy := &AccessListTx{
Nonce: tx.Nonce,
To: tx.To.CopyPointer(),
To: tx.To.Clone(),
Data: common.CopyBytes(tx.Data),
Gas: tx.Gas,
// These are copied below.
Expand Down
2 changes: 1 addition & 1 deletion core/types/dynamic_fee_tx.go
Expand Up @@ -43,7 +43,7 @@ type DynamicFeeTx struct {
func (tx *DynamicFeeTx) copy() TxData {
cpy := &DynamicFeeTx{
Nonce: tx.Nonce,
To: tx.To.CopyPointer(),
To: tx.To.Clone(),
Data: common.CopyBytes(tx.Data),
Gas: tx.Gas,
// These are copied below.
Expand Down
2 changes: 1 addition & 1 deletion core/types/legacy_tx.go
Expand Up @@ -62,7 +62,7 @@ func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPric
func (tx *LegacyTx) copy() TxData {
cpy := &LegacyTx{
Nonce: tx.Nonce,
To: tx.To.CopyPointer(),
To: tx.To.Clone(),
Data: common.CopyBytes(tx.Data),
Gas: tx.Gas,
// These are initialized below.
Expand Down

0 comments on commit b60f145

Please sign in to comment.