-
Notifications
You must be signed in to change notification settings - Fork 217
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
Allow deleting expired transactions from the API #2262
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4eceb7e
Also permit deleting expired transactions
rvl 594d7c3
Simplify mRemovePendingTx model and state machine
rvl 9cee2c6
Add integration test for deleting expired transactions
rvl 77ca6c8
Review rework
rvl d9da868
Mark test TRANS_TTL_DELETE_01 pending
rvl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ module Cardano.Wallet.DB | |
, gapSize | ||
|
||
-- * Errors | ||
, ErrRemovePendingTx (..) | ||
, ErrRemoveTx (..) | ||
, ErrNoSuchWallet(..) | ||
, ErrWalletAlreadyExists(..) | ||
) where | ||
|
@@ -252,10 +252,10 @@ data DBLayer m s k = forall stm. (MonadIO stm, MonadFail stm) => DBLayer | |
-- ^ Removes any expired transactions from the pending set and marks | ||
-- their status as expired. | ||
|
||
, removePendingTx | ||
, removePendingOrExpiredTx | ||
:: PrimaryKey WalletId | ||
-> Hash "Tx" | ||
-> ExceptT ErrRemovePendingTx stm () | ||
-> ExceptT ErrRemoveTx stm () | ||
-- ^ Manually remove a pending transaction. | ||
|
||
, putPrivateKey | ||
|
@@ -310,11 +310,11 @@ newtype ErrNoSuchWallet | |
= ErrNoSuchWallet WalletId -- Wallet is gone or doesn't exist yet | ||
deriving (Eq, Show) | ||
|
||
-- | Can't perform removing pending transaction | ||
data ErrRemovePendingTx | ||
= ErrRemovePendingTxNoSuchWallet ErrNoSuchWallet | ||
| ErrRemovePendingTxNoSuchTransaction (Hash "Tx") | ||
| ErrRemovePendingTxTransactionNoMorePending (Hash "Tx") | ||
-- | Can't remove pending or expired transaction. | ||
data ErrRemoveTx | ||
= ErrRemoveTxNoSuchWallet ErrNoSuchWallet | ||
| ErrRemoveTxNoSuchTransaction (Hash "Tx") | ||
| ErrRemoveTxAlreadyInLedger (Hash "Tx") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
deriving (Eq, Show) | ||
|
||
-- | Can't perform given operation because there's no transaction | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,14 +23,13 @@ import Cardano.Address.Derivation | |
import Cardano.Wallet.DB | ||
( DBLayer (..) | ||
, ErrNoSuchWallet (..) | ||
, ErrRemovePendingTx (..) | ||
, ErrRemoveTx (..) | ||
, ErrWalletAlreadyExists (..) | ||
, PrimaryKey (..) | ||
) | ||
import Cardano.Wallet.DB.Model | ||
( Database | ||
, Err (..) | ||
, ErrErasePendingTx (..) | ||
, ModelOp | ||
, emptyDatabase | ||
, mCheckWallet | ||
|
@@ -51,7 +50,7 @@ import Cardano.Wallet.DB.Model | |
, mReadProtocolParameters | ||
, mReadTxHistory | ||
, mReadWalletMeta | ||
, mRemovePendingTx | ||
, mRemovePendingOrExpiredTx | ||
, mRemoveWallet | ||
, mRollbackTo | ||
, mUpdatePendingTxForExpiry | ||
|
@@ -178,8 +177,8 @@ newDBLayer timeInterpreter = do | |
, updatePendingTxForExpiry = \pk tip -> ExceptT $ do | ||
alterDB errNoSuchWallet db (mUpdatePendingTxForExpiry pk tip) | ||
|
||
, removePendingTx = \pk tid -> ExceptT $ do | ||
alterDB errCannotRemovePendingTx db (mRemovePendingTx pk tid) | ||
, removePendingOrExpiredTx = \pk tid -> ExceptT $ do | ||
alterDB errCannotRemovePendingTx db (mRemovePendingOrExpiredTx pk tid) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
{----------------------------------------------------------------------- | ||
Protocol Parameters | ||
|
@@ -238,13 +237,13 @@ errNoSuchWallet :: Err (PrimaryKey WalletId) -> Maybe ErrNoSuchWallet | |
errNoSuchWallet (NoSuchWallet (PrimaryKey wid)) = Just (ErrNoSuchWallet wid) | ||
errNoSuchWallet _ = Nothing | ||
|
||
errCannotRemovePendingTx :: Err (PrimaryKey WalletId) -> Maybe ErrRemovePendingTx | ||
errCannotRemovePendingTx (CannotRemovePendingTx (ErrErasePendingTxNoSuchWallet (PrimaryKey wid))) = | ||
Just (ErrRemovePendingTxNoSuchWallet (ErrNoSuchWallet wid)) | ||
errCannotRemovePendingTx (CannotRemovePendingTx (ErrErasePendingTxNoTx tid)) = | ||
Just (ErrRemovePendingTxNoSuchTransaction tid) | ||
errCannotRemovePendingTx (CannotRemovePendingTx (ErrErasePendingTxNoPendingTx tid)) = | ||
Just (ErrRemovePendingTxTransactionNoMorePending tid) | ||
errCannotRemovePendingTx :: Err (PrimaryKey WalletId) -> Maybe ErrRemoveTx | ||
errCannotRemovePendingTx (NoSuchWallet (PrimaryKey wid)) = | ||
Just (ErrRemoveTxNoSuchWallet (ErrNoSuchWallet wid)) | ||
errCannotRemovePendingTx (NoSuchTx _ tid) = | ||
Just (ErrRemoveTxNoSuchTransaction tid) | ||
errCannotRemovePendingTx (CantRemoveTxInLedger _ tid) = | ||
Just (ErrRemoveTxAlreadyInLedger tid) | ||
errCannotRemovePendingTx _ = Nothing | ||
|
||
errWalletAlreadyExists | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to add tests forgetting expired transactions that:
I'm guessing it doesn't matter but perhaps it's good to have such cases in regression suite, just in case.
(As far as I see, playing manually, there's no problem forgetting such expired transactions)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confident that TTL is completely independent from these things.