Skip to content

Commit

Permalink
DBManager WIP (#1512)
Browse files Browse the repository at this point in the history
* WIP

* WIP

* WIP
  • Loading branch information
ToniRamirezM committed Jan 9, 2023
1 parent b3c3ccf commit 201ea32
Show file tree
Hide file tree
Showing 11 changed files with 452 additions and 149 deletions.
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

0 comments on commit 201ea32

Please sign in to comment.