Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@

tcount := w.current.tcount

w.commitTransactions(w.current, plainTxs, blobTxs, nil, new(uint256.Int))
w.commitTransactions(w.current, plainTxs, blobTxs, nil)
stopFn()

// Only update the snapshot if any new transactons were added
Expand Down Expand Up @@ -959,11 +959,12 @@
}
env.txs = append(env.txs, tx)
env.receipts = append(env.receipts, receipt)
env.tcount++
Comment thread
kamuikatsurgi marked this conversation as resolved.

return receipt.Logs, nil
}

func (w *worker) commitTransactions(env *environment, plainTxs, blobTxs *transactionsByPriceAndNonce, interrupt *atomic.Int32, minTip *uint256.Int) error {
func (w *worker) commitTransactions(env *environment, plainTxs, blobTxs *transactionsByPriceAndNonce, interrupt *atomic.Int32) error {

Check failure on line 967 in miner/worker.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 115 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=0xPolygon_bor&issues=AZq0RzMxoUy-WwKz0hwt&open=AZq0RzMxoUy-WwKz0hwt&pullRequest=1903
defer func(t0 time.Time) {
commitTransactionsTimer.Update(time.Since(t0))
}(time.Now())
Expand Down Expand Up @@ -1072,11 +1073,6 @@
continue
}

// If we don't receive enough tip for the next transaction, skip the account
if ptip.Cmp(minTip) < 0 {
Comment thread
kamuikatsurgi marked this conversation as resolved.
log.Trace("Not enough tip for transaction", "hash", ltx.Hash, "tip", ptip, "needed", minTip)
break // If the next-best is too low, surely no better will be available
}
// Transaction seems to fit, pull it up from the pool
tx := ltx.Resolve()
if tx == nil {
Expand Down Expand Up @@ -1155,7 +1151,6 @@
case errors.Is(err, nil):
// Everything ok, collect the logs and shift in the next transaction from the same account
coalescedLogs = append(coalescedLogs, logs...)
env.tcount++

if EnableMVHashMap && w.IsRunning() {
env.depsMVFullWriteList = append(env.depsMVFullWriteList, env.state.MVFullWriteList())
Expand Down Expand Up @@ -1455,8 +1450,7 @@
if len(prioPlainTxs) > 0 || len(prioBlobTxs) > 0 {
plainTxs := newTransactionsByPriceAndNonce(env.signer, prioPlainTxs, env.header.BaseFee, &w.interruptBlockBuilding)
blobTxs := newTransactionsByPriceAndNonce(env.signer, prioBlobTxs, env.header.BaseFee, &w.interruptBlockBuilding)

if err := w.commitTransactions(env, plainTxs, blobTxs, interrupt, new(uint256.Int)); err != nil {
if err := w.commitTransactions(env, plainTxs, blobTxs, interrupt); err != nil {
return err
}
}
Expand All @@ -1466,7 +1460,7 @@
blobTxs := newTransactionsByPriceAndNonce(env.signer, normalBlobTxs, env.header.BaseFee, &w.interruptBlockBuilding)
txHeapInitTimer.Update(time.Since(heapInitTime))

if err := w.commitTransactions(env, plainTxs, blobTxs, interrupt, new(uint256.Int)); err != nil {
if err := w.commitTransactions(env, plainTxs, blobTxs, interrupt); err != nil {
return err
}
}
Expand Down
Loading