-
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
Add tx metadata to sqlite database #2091
Conversation
9660fd1
to
c003df8
Compare
ba83ded
to
84fefa6
Compare
b9d1b1a
to
d7ca998
Compare
84fefa6
to
d416430
Compare
d416430
to
8c98ca5
Compare
@@ -128,13 +129,13 @@ import Data.Either | |||
import Data.Generics.Internal.VL.Lens | |||
( (^.) ) | |||
import Data.List | |||
( nub, sortOn, unzip3 ) | |||
( nub, sortOn, unzip4 ) |
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 how it started with just unzip2 and gradually increased. We still have 3 left, after which we have to stop further development :)
dbChunked repsertMany | ||
[ (TxInKey txInputTxId txInputSourceTxId txInputSourceIndex, i) | ||
| i@TxIn{..} <- txins ] | ||
dbChunked repsertMany | ||
[ (TxOutKey txOutputTxId txOutputIndex, o) | ||
| o@TxOut{..} <- txouts ] | ||
forM_ (chunksOf chunkSize $ map txMetaTxId metas) $ \txids -> | ||
deleteWhere [ TxMetadataTxId <-. txids ] |
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 the delete? Isn't the point of repsert
to "replace or insert"?
, concatMap (fst . (\(_,b,_,_) -> b)) entities | ||
, concatMap (snd . (\(_,b,_,_) -> b)) entities | ||
, concatMap (\(_,_,c,_) -> maybeToList c) entities | ||
, concatMap (\(_,_,_,d) -> d) entities | ||
) |
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.
Wouldn't be more efficient and simpler to store metadata with the rest of the static data (status, direction etc..)?
We have to resort to separate database tables for TxIn, TxOut and TxWithdrawals because they are unbounded (modulo tx size) lists. Metadata however can be treated as a bunch of bytes that are either present or not.
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.
My reason was just that sqlite tables don't cost much and it seemed like it would be confusing to have data in the TxMeta
table which was actually a field of Tx
.
txMetadataValue W.TxMetadata sql=value | ||
|
||
Primary txMetadataTxId | ||
deriving Show Generic |
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 a bit doubtful about having this as a separate table (cf earlier comment).
8c98ca5
to
c43d093
Compare
This is more efficient than storing them in separate tables like inputs and outputs and also a bit less awkward when it comes to fetching metadata corresponding to each transactions back.
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.
Temporarily worked-around the roundtripping issues until #2098 is fixed. state-machine tests pass for now.
Thanks bors r+ |
Build succeeded |
Issue Number
ADP-307 / #2072
Overview
Includes transaction metadata in the sqlite database transaction history.
Comments