Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit a74f4a0

Browse files
committed
[CBR-495] Make UndisputableLookupFailed lenient, since we may end up with no Txs-Accounts relations in SQlite
1 parent 2b0a021 commit a74f4a0

File tree

1 file changed

+6
-7
lines changed
  • wallet-new/src/Cardano/Wallet/Kernel/DB

1 file changed

+6
-7
lines changed

wallet-new/src/Cardano/Wallet/Kernel/DB/Sqlite.hs

+6-7
Original file line numberDiff line numberDiff line change
@@ -498,17 +498,16 @@ putTxMetaT conn txMeta =
498498
-- This is the only acceptable exception here. If anything else is thrown, that`s an error.
499499
t <- getTxMetasById conn txId
500500
case (Kernel.txIdIsomorphic txMeta <$> t) of
501-
Nothing ->
502-
-- Output is there but not TxMeta. This should never happen.
503-
-- This could be improved with foreign keys, which indicate
504-
-- the existence of at least one Meta entry for each Output.
505-
throwIO $ Kernel.InvariantViolated (Kernel.UndisputableLookupFailed "txId")
506501
Just False ->
507502
-- This violation means the Tx has same TxId but different
508503
-- Inputs (as set) or Outputs (ordered).
509504
throwIO $ Kernel.InvariantViolated (Kernel.TxIdInvariantViolated txId)
510-
Just True -> do
511-
-- If there not a TxId violation, we can try to insert TxMeta.
505+
_ -> do
506+
-- If there is not a TxId violation, we can try to insert TxMeta.
507+
-- We handle Nothing and (Just True) the same here, since
508+
-- it's possible that there is no Meta with this Inputs/Outputs.
509+
-- In the future we may consider doing a better cleanup to avoid
510+
-- such cases.
512511
res2 <- Sqlite.runDBAction $ runBeamSqlite conn $
513512
SQL.runInsert $ SQL.insert (_mDbMeta metaDB) $ SQL.insertValues [tMeta]
514513
case res2 of

0 commit comments

Comments
 (0)