Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TXM In-memory: step 3-02-PruneUnstartedTxQueue #12227

Merged

Conversation

poopoothegorilla
Copy link
Contributor

NOTES:

  • Implements PruneUnstartedTxQueue

Parent:

Copy link
Contributor

I see that you haven't updated any README files. Would it make sense to do so?

@cl-sonarqube-production
Copy link

Quality Gate failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube

Catch issues before they fail your Quality Gate with our IDE extension SonarLint SonarLint

Comment on lines +183 to +208
for _, txState := range txStates {
switch txState {
case TxUnstarted:
filter2 := func(tx *txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) bool {
if tx.State != TxUnstarted {
return false
}
return filter(tx)
}
txs = append(txs, as._findTxs(as.allTxs, filter2, txIDs...)...)
case TxInProgress:
if as.inprogressTx != nil && filter(as.inprogressTx) {
txs = append(txs, *as.inprogressTx)
}
case TxUnconfirmed:
txs = append(txs, as._findTxs(as.unconfirmedTxs, filter, txIDs...)...)
case TxConfirmedMissingReceipt:
txs = append(txs, as._findTxs(as.confirmedMissingReceiptTxs, filter, txIDs...)...)
case TxConfirmed:
txs = append(txs, as._findTxs(as.confirmedTxs, filter, txIDs...)...)
case TxFatalError:
txs = append(txs, as._findTxs(as.fatalErroredTxs, filter, txIDs...)...)
default:
panic("findTxs: unknown transaction state")
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be also be optimized if we use map[State]map[ID][]*Tx

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great point! I think that could be useful for the next iteration of this work. This code is still pretty EVM specific. your suggestion is a bit more generalized and might be a good next step for this. With all that being said I think we should hold off on that work for a future refactor.

Copy link
Contributor

@DylanTinianov DylanTinianov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but should be optimized later.

@poopoothegorilla poopoothegorilla marked this pull request as ready for review March 29, 2024 19:30
@poopoothegorilla poopoothegorilla requested a review from a team as a code owner March 29, 2024 19:30
@poopoothegorilla poopoothegorilla merged commit 854225a into jtw/step-3-02 Mar 29, 2024
108 of 114 checks passed
@poopoothegorilla poopoothegorilla deleted the jtw/step-3-02-prune-unstarted-tx-queue branch March 29, 2024 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants