Skip to content

Commit

Permalink
Change sqlite to not have datum in transactions_outputs table
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeinsky committed May 30, 2023
1 parent da3af57 commit dd93068
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions marconi-chain-index/src/Marconi/ChainIndex/Indexers/Utxo.hs
Expand Up @@ -415,7 +415,6 @@ instance ToRow UtxoRow where
[ toField (u ^. urUtxo . address)
, toField txId
, toField txIx
, toField (u ^. urUtxo . datum)
, toField (u ^. urUtxo . datumHash)
, toField (u ^. urUtxo . value)
, toField (u ^. urUtxo . inlineScript)
Expand Down Expand Up @@ -471,7 +470,6 @@ open dbPath (Depth k) isToVacuume = do
( address TEXT NOT NULL
, txId TEXT NOT NULL
, txIx INT NOT NULL
, datum BLOB
, datumHash BLOB
, value BLOB
, inlineScript BLOB
Expand Down Expand Up @@ -524,7 +522,6 @@ instance Buffered UtxoHandle where
address,
txId,
txIx,
datum,
datumHash,
value,
inlineScript,
Expand All @@ -536,7 +533,7 @@ instance Buffered UtxoHandle where
spentTxId,
txIndexInBlock
) VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|] rows
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|] rows
SQL.executeMany c
[r|UPDATE transactions_outputs
SET spentSlotNo = ?,
Expand Down Expand Up @@ -573,7 +570,7 @@ instance Buffered UtxoHandle where
u.address,
u.txId,
u.txIx,
u.datum,
d.datum,
u.datumHash,
u.value,
u.inlineScript,
Expand All @@ -584,8 +581,8 @@ instance Buffered UtxoHandle where
u.spentSlotNo,
u.spentBlockHash,
u.spentTxId
FROM
transactions_outputs u
FROM transactions_outputs u
LEFT JOIN datumhash_datum d ON u.datumHash = d.datum_hash
WHERE
u.slotNo >= ?
GROUP by
Expand Down Expand Up @@ -779,7 +776,7 @@ utxoAtAddressQuery c bufferResult filters params
u.address,
u.txId,
u.txIx,
u.datum,
d.datum,
u.datumHash,
u.value,
u.inlineScript,
Expand All @@ -790,8 +787,8 @@ utxoAtAddressQuery c bufferResult filters params
u.spentSlotNo,
u.spentBlockHash,
u.spentTxId
FROM
transactions_outputs u
FROM transactions_outputs u
LEFT JOIN datumhash_datum d ON u.datumHash = d.datum_hash
WHERE |] <> SQL.Query (Text.intercalate " AND " $ SQL.fromQuery <$> filters) <>
[r| ORDER BY u.slotNo ASC |]
persistedUtxoRows :: [UtxoRow] <- SQL.queryNamed c builtQuery params
Expand Down

0 comments on commit dd93068

Please sign in to comment.