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

DBManager WIP #1512

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions pool/pgpoolstorage/pgpoolstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,3 +533,12 @@ func scanTx(rows pgx.Rows) (*pool.Transaction, error) {

return tx, nil
}

// DeleteTransactionByHash deletes tx by its hash
func (p *PostgresPoolStorage) DeleteTransactionByHash(ctx context.Context, hash common.Hash) error {
query := "DELETE FROM pool.txs WHERE hash = $1"
if _, err := p.db.Exec(ctx, query, hash); err != nil {
return err
}
return nil
}
4 changes: 4 additions & 0 deletions pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ func (p *Pool) checkTxFieldCompatibilityWithExecutor(ctx context.Context, tx typ

// MarkReorgedTxsAsPending updated reorged txs status from selected to pending
func (p *Pool) MarkReorgedTxsAsPending(ctx context.Context) error {
// TODO: Change status to "reorged"

// get selected transactions from pool
selectedTxs, err := p.GetSelectedTxs(ctx, 0)
if err != nil {
Expand All @@ -266,3 +268,5 @@ func (p *Pool) MarkReorgedTxsAsPending(ctx context.Context) error {

return nil
}

// TODO: Create a method for the synchronizer to update Tx Statuses to "pending" or "reorged"
4 changes: 3 additions & 1 deletion pool/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ const (
TxStatusPending TxStatus = "pending"
// TxStatusInvalid represents an invalid tx
TxStatusInvalid TxStatus = "invalid"
// TxStatusSelected represents a tx that has been selected
// TxStatusSelected represents a tx that has been selected
TxStatusSelected TxStatus = "selected"
// TxStatusFailed represents a tx that has been failed after processing, but can be processed in the future
TxStatusFailed TxStatus = "failed"
// TxStatusWIP represents a tx that is in a sequencer worker memory
TxStatusWIP TxStatus = "wip"
)

// TxStatus represents the state of a tx
Expand Down