Skip to content

Commit

Permalink
fix: dev: deep copy receipt
Browse files Browse the repository at this point in the history
  • Loading branch information
Jolly23 committed Mar 15, 2024
1 parent a0a39d1 commit e9b1995
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions core/types/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,31 @@ func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, nu
// CopyReceipts makes a deep copy of the given receipts.
func CopyReceipts(receipts []*Receipt) []*Receipt {
result := make([]*Receipt, len(receipts))
for i, l := range receipts {
cpy := *l
for i, src := range receipts {
// deep copy the receipt
cpy := Receipt{
Type: src.Type,
PostState: make([]byte, len(src.PostState)),
Status: src.Status,
CumulativeGasUsed: src.CumulativeGasUsed,
Bloom: src.Bloom,
Logs: make([]*Log, len(src.Logs)),
TxHash: src.TxHash,
ContractAddress: src.ContractAddress,
GasUsed: src.GasUsed,
EffectiveGasPrice: new(big.Int).Set(src.EffectiveGasPrice),
BlobGasUsed: src.BlobGasUsed,
BlobGasPrice: new(big.Int).Set(src.BlobGasPrice),
BlockHash: src.BlockHash,
BlockNumber: new(big.Int).Set(src.BlockNumber),
TransactionIndex: src.TransactionIndex,
}
copy(cpy.PostState, src.PostState)
copy(cpy.Bloom[:], src.Bloom.Bytes())
for j, log := range src.Logs {
theL := *log
cpy.Logs[j] = &theL
}
result[i] = &cpy
}
return result
Expand Down

0 comments on commit e9b1995

Please sign in to comment.