Skip to content

Commit 6e71162

Browse files
committed
miner: minor feehistory fixes (ethereum#23178)
1 parent 919845d commit 6e71162

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

miner/worker.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ type worker struct {
128128
coinbase common.Address
129129
extra []byte
130130

131-
snapshotMu sync.RWMutex // The lock used to protect the block snapshot and state snapshot
131+
snapshotMu sync.RWMutex // The lock used to protect the snapshots below
132132
snapshotBlock *types.Block
133133
snapshotReceipts types.Receipts
134134
snapshotState *state.StateDB
@@ -475,6 +475,16 @@ func (self *worker) push(work *Work) {
475475
}
476476
}
477477

478+
// copyReceipts makes a deep copy of the given receipts.
479+
func copyReceipts(receipts []*types.Receipt) []*types.Receipt {
480+
result := make([]*types.Receipt, len(receipts))
481+
for i, l := range receipts {
482+
cpy := *l
483+
result[i] = &cpy
484+
}
485+
return result
486+
}
487+
478488
// makeCurrent creates a new environment for the current cycle.
479489
func (self *worker) makeCurrent(parent *types.Block, header *types.Header) error {
480490
// Retrieve the parent state to execute on top and start a prefetcher for
@@ -534,7 +544,7 @@ func (w *worker) updateSnapshot() {
534544
nil,
535545
w.current.receipts,
536546
)
537-
w.snapshotReceipts = w.current.receipts
547+
w.snapshotReceipts = copyReceipts(w.current.receipts)
538548
w.snapshotState = w.current.state.Copy()
539549
}
540550

0 commit comments

Comments
 (0)