Skip to content

Commit

Permalink
Remove the snapshot from worker
Browse files Browse the repository at this point in the history
  • Loading branch information
kiltsonfire authored and gameofpointers committed May 31, 2023
1 parent c004b94 commit f074475
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions core/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,6 @@ func (w *worker) GeneratePendingHeader(block *types.Block, fill bool) (*types.He
}
work.header = block.Header()
w.printPendingHeaderInfo(work, block, start)
w.updateSnapshot(work)

return work.header, nil
}
Expand Down Expand Up @@ -573,14 +572,8 @@ func (w *worker) mainLoop() {
txs[acc.Bytes20()] = append(txs[acc.Bytes20()], tx)
}
txset := types.NewTransactionsByPriceAndNonce(w.current.signer, txs, w.current.header.BaseFee(), false)
tcount := w.current.tcount
w.commitTransactions(w.current, txset, nil)

// Only update the snapshot if any new transactions were added
// to the pending block
if tcount != w.current.tcount {
w.updateSnapshot(w.current)
}
}
atomic.AddInt32(&w.newTxs, int32(len(ev.Txs)))

Expand Down Expand Up @@ -664,22 +657,6 @@ func (w *worker) commitUncle(env *environment, uncle *types.Header) error {
return nil
}

// updateSnapshot updates pending snapshot block, receipts and state.
func (w *worker) updateSnapshot(env *environment) {
w.snapshotMu.Lock()
defer w.snapshotMu.Unlock()

w.snapshotBlock = types.NewBlock(
env.header,
env.txs,
env.unclelist(),
env.etxs,
env.subManifest,
env.receipts,
trie.NewStackTrie(nil),
)
}

func (w *worker) commitTransaction(env *environment, tx *types.Transaction) ([]*types.Log, error) {
if tx != nil {
snap := env.state.Snapshot()
Expand Down Expand Up @@ -1028,9 +1005,7 @@ func (w *worker) commit(env *environment, interval func(), update bool, start ti
}

}
if update {
w.updateSnapshot(env)
}

return nil
}

Expand Down

0 comments on commit f074475

Please sign in to comment.