-
Notifications
You must be signed in to change notification settings - Fork 214
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
Cardano.Wallet.DB.Model #660
Conversation
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 like where this is going! lgtm.
-- data store. | ||
-- Dummy implementation of the database-layer, using 'MVar'. This may be good | ||
-- for testing to compare with an implementation on a real data store, or to use | ||
-- when compiling the wallet for targets which don't have SQLite. |
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.
👍
filterTxHistory :: SortOrder -> Range SlotId -> TxHistory t -> TxHistory t | ||
filterTxHistory order range = | ||
filter ((`isWithinRange` range) . slotId . snd . snd) | ||
. (case order of |
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.
We could use sortBy
+ Down
instead of sortOn
+ reverse
to traverse the list one time less, if it matters for performance.
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 wanted this code to be as simple and obvious as possible given that inefficiency doesn't matter in this case (particularly not linear slowdowns). So when I cut & pasted this function I was happy to leave it as it was.
data Database wid s t xprv = Database | ||
{ wallets :: !(Map wid (WalletDatabase s t xprv)) | ||
-- ^ Wallet-related information. | ||
, txs :: (Map (Hash "Tx") (Tx t)) |
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.
Why do we need Tx
s? And why globally? It is not in your sqlite schema diagram.
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.
Ah yes, it's not in that diagram because it only has tables/columns relevant to rollback.
But in the full schema, a Tx is just all rows of tx_in and tx_out that share a txid. Because transactions are immutable, they are not attached to any wallet.
Relates to #641.
Overview
Cardano.Wallet.DB.Model
module based on both the MVar DBLayer and the QSM tests model.