@@ -53,9 +53,9 @@ module Cardano.DbSync.Config.Types (
53
53
isMultiAssetEnabled ,
54
54
isMetadataEnabled ,
55
55
isPlutusEnabled ,
56
- isTxOutBootstrap ,
56
+ isTxOutConsumedBootstrap ,
57
57
isTxOutConsumed ,
58
- isTxOutPrune ,
58
+ isTxOutConsumedPrune ,
59
59
forceTxIn ,
60
60
fullInsertOptions ,
61
61
onlyUTxOInsertOptions ,
@@ -184,7 +184,6 @@ data SyncInsertOptions = SyncInsertOptions
184
184
, sioPoolStats :: PoolStatsConfig
185
185
, sioJsonType :: JsonTypeConfig
186
186
, sioRemoveJsonbFromSchema :: RemoveJsonbFromSchemaConfig
187
- , sioTxOutTableType :: TxOutTableTypeConfig
188
187
}
189
188
deriving (Eq , Show )
190
189
@@ -199,17 +198,21 @@ newtype PoolStatsConfig = PoolStatsConfig
199
198
deriving (Eq , Show )
200
199
201
200
data TxOutConfig
202
- = TxOutEnable
201
+ = TxOutEnable UseTxOutAddress
203
202
| TxOutDisable
204
- | TxOutConsumed ForceTxIn
205
- | TxOutPrune ForceTxIn
206
- | TxOutBootstrap ForceTxIn
203
+ | TxOutConsumed ForceTxIn UseTxOutAddress
204
+ | TxOutConsumedPrune ForceTxIn UseTxOutAddress
205
+ | TxOutConsumedBootstrap ForceTxIn UseTxOutAddress
207
206
deriving (Eq , Show )
208
207
209
208
newtype ForceTxIn = ForceTxIn { unForceTxIn :: Bool }
210
209
deriving (Eq , Show )
211
210
deriving newtype (ToJSON , FromJSON )
212
211
212
+ newtype UseTxOutAddress = UseTxOutAddress { unUseTxOutAddress :: Bool }
213
+ deriving (Eq , Show )
214
+ deriving newtype (ToJSON , FromJSON )
215
+
213
216
data LedgerInsertConfig
214
217
= LedgerEnable
215
218
| LedgerDisable
@@ -326,28 +329,28 @@ pcNodeConfigFilePath = unNodeConfigFile . pcNodeConfigFile
326
329
327
330
isTxOutEnabled :: TxOutConfig -> Bool
328
331
isTxOutEnabled TxOutDisable = False
329
- isTxOutEnabled TxOutEnable = True
330
- isTxOutEnabled (TxOutConsumed _) = True
331
- isTxOutEnabled (TxOutPrune _) = True
332
- isTxOutEnabled (TxOutBootstrap _) = True
332
+ isTxOutEnabled ( TxOutEnable _) = True
333
+ isTxOutEnabled (TxOutConsumed _ _ ) = True
334
+ isTxOutEnabled (TxOutConsumedPrune _ _) = True
335
+ isTxOutEnabled (TxOutConsumedBootstrap _ _) = True
333
336
334
- isTxOutBootstrap :: TxOutConfig -> Bool
335
- isTxOutBootstrap ( TxOutBootstrap _) = True
336
- isTxOutBootstrap _ = False
337
+ isTxOutConsumedBootstrap :: TxOutConfig -> Bool
338
+ isTxOutConsumedBootstrap ( TxOutConsumedBootstrap _ _) = True
339
+ isTxOutConsumedBootstrap _ = False
337
340
338
341
isTxOutConsumed :: TxOutConfig -> Bool
339
- isTxOutConsumed (TxOutConsumed _) = True
342
+ isTxOutConsumed (TxOutConsumed _ _ ) = True
340
343
isTxOutConsumed _ = False
341
344
342
- isTxOutPrune :: TxOutConfig -> Bool
343
- isTxOutPrune ( TxOutPrune _) = True
344
- isTxOutPrune _ = False
345
+ isTxOutConsumedPrune :: TxOutConfig -> Bool
346
+ isTxOutConsumedPrune ( TxOutConsumedPrune _ _) = True
347
+ isTxOutConsumedPrune _ = False
345
348
346
349
forceTxIn :: TxOutConfig -> Bool
347
- forceTxIn (TxOutConsumed f) = unForceTxIn f
348
- forceTxIn (TxOutPrune f ) = unForceTxIn f
349
- forceTxIn (TxOutBootstrap f ) = unForceTxIn f
350
- forceTxIn TxOutEnable = False
350
+ forceTxIn (TxOutConsumed f _ ) = unForceTxIn f
351
+ forceTxIn (TxOutConsumedPrune f _ ) = unForceTxIn f
352
+ forceTxIn (TxOutConsumedBootstrap f _ ) = unForceTxIn f
353
+ forceTxIn ( TxOutEnable _) = False
351
354
forceTxIn TxOutDisable = False
352
355
353
356
hasLedger :: LedgerInsertConfig -> Bool
@@ -446,7 +449,6 @@ parseOverrides obj baseOptions = do
446
449
<*> obj .:? " pool_stats" .!= sioPoolStats baseOptions
447
450
<*> obj .:? " json_type" .!= sioJsonType baseOptions
448
451
<*> obj .:? " remove_jsonb_from_schema" .!= sioRemoveJsonbFromSchema baseOptions
449
- <*> obj .:? " use_address_table" .!= sioAddress baseOptions
450
452
451
453
instance ToJSON SyncInsertConfig where
452
454
toJSON (SyncInsertConfig preset options) =
@@ -467,7 +469,6 @@ optionsToList SyncInsertOptions {..} =
467
469
, toJsonIfSet " offchain_pool_data" sioOffchainPoolData
468
470
, toJsonIfSet " pool_stats" sioPoolStats
469
471
, toJsonIfSet " json_type" sioJsonType
470
- , toJsonIfSet " remove_jsonb_from_schema" sioRemoveJsonbFromSchema
471
472
]
472
473
473
474
toJsonIfSet :: ToJSON a => Text -> a -> Maybe Pair
@@ -489,7 +490,6 @@ instance FromJSON SyncInsertOptions where
489
490
<*> obj .:? " pool_stat" .!= sioPoolStats def
490
491
<*> obj .:? " json_type" .!= sioJsonType def
491
492
<*> obj .:? " remove_jsonb_from_schema" .!= sioRemoveJsonbFromSchema def
492
- <*> obj .:? " use_address_table" .!= sioAddress def
493
493
494
494
instance ToJSON SyncInsertOptions where
495
495
toJSON SyncInsertOptions {.. } =
@@ -534,33 +534,42 @@ instance ToJSON TxOutConfig where
534
534
Aeson. object
535
535
[ " value" .= value cfg
536
536
, " force_tx_in" .= forceTxIn' cfg
537
+ , " use_address_table" .= useTxOutAddress' cfg
537
538
]
538
539
where
539
540
value :: TxOutConfig -> Text
540
- value TxOutEnable = " enable"
541
+ value ( TxOutEnable _) = " enable"
541
542
value TxOutDisable = " disable"
542
- value (TxOutConsumed _) = " consumed"
543
- value (TxOutPrune _) = " prune"
544
- value (TxOutBootstrap _) = " bootstrap"
543
+ value (TxOutConsumed _ _ ) = " consumed"
544
+ value (TxOutConsumedPrune _ _) = " prune"
545
+ value (TxOutConsumedBootstrap _ _) = " bootstrap"
545
546
546
547
forceTxIn' :: TxOutConfig -> Maybe Bool
547
- forceTxIn' TxOutEnable = Nothing
548
+ forceTxIn' ( TxOutEnable _) = Nothing
548
549
forceTxIn' TxOutDisable = Nothing
549
- forceTxIn' (TxOutConsumed f) = Just (unForceTxIn f)
550
- forceTxIn' (TxOutPrune f) = Just (unForceTxIn f)
551
- forceTxIn' (TxOutBootstrap f) = Just (unForceTxIn f)
550
+ forceTxIn' (TxOutConsumed f _) = Just (unForceTxIn f)
551
+ forceTxIn' (TxOutConsumedPrune f _) = Just (unForceTxIn f)
552
+ forceTxIn' (TxOutConsumedBootstrap f _) = Just (unForceTxIn f)
553
+
554
+ useTxOutAddress' :: TxOutConfig -> Maybe Bool
555
+ useTxOutAddress' (TxOutEnable u) = Just (unUseTxOutAddress u)
556
+ useTxOutAddress' TxOutDisable = Nothing
557
+ useTxOutAddress' (TxOutConsumed _ u) = Just (unUseTxOutAddress u)
558
+ useTxOutAddress' (TxOutConsumedPrune _ u) = Just (unUseTxOutAddress u)
559
+ useTxOutAddress' (TxOutConsumedBootstrap _ u) = Just (unUseTxOutAddress u)
552
560
553
561
instance FromJSON TxOutConfig where
554
562
parseJSON = Aeson. withObject " tx_out" $ \ obj -> do
555
563
val <- obj .: " value"
564
+ useAddress' <- obj .: " use_address_table" .!= UseTxOutAddress False
556
565
forceTxIn' <- obj .:? " force_tx_in" .!= ForceTxIn False
557
566
558
567
case val :: Text of
559
- " enable" -> pure TxOutEnable
568
+ " enable" -> pure ( TxOutEnable useAddress')
560
569
" disable" -> pure TxOutDisable
561
- " consumed" -> pure (TxOutConsumed forceTxIn')
562
- " prune" -> pure (TxOutPrune forceTxIn')
563
- " bootstrap" -> pure (TxOutBootstrap forceTxIn')
570
+ " consumed" -> pure (TxOutConsumed forceTxIn' useAddress' )
571
+ " prune" -> pure (TxOutConsumedPrune forceTxIn' useAddress ')
572
+ " bootstrap" -> pure (TxOutConsumedBootstrap forceTxIn' useAddress ')
564
573
other -> fail $ " unexpected tx_out: " <> show other
565
574
566
575
instance ToJSON LedgerInsertConfig where
@@ -714,7 +723,7 @@ instance Default SyncInsertOptions where
714
723
def =
715
724
SyncInsertOptions
716
725
{ sioTxCBOR = TxCBORConfig False
717
- , sioTxOut = TxOutEnable
726
+ , sioTxOut = TxOutEnable ( UseTxOutAddress False )
718
727
, sioLedger = LedgerEnable
719
728
, sioShelley = ShelleyEnable
720
729
, sioRewards = RewardsConfig True
@@ -726,14 +735,13 @@ instance Default SyncInsertOptions where
726
735
, sioPoolStats = PoolStatsConfig False
727
736
, sioJsonType = JsonTypeText
728
737
, sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
729
- , sioTxOutTableType = TxOutTableTypeConfig False
730
738
}
731
739
732
740
fullInsertOptions :: SyncInsertOptions
733
741
fullInsertOptions =
734
742
SyncInsertOptions
735
743
{ sioTxCBOR = TxCBORConfig False
736
- , sioTxOut = TxOutEnable
744
+ , sioTxOut = TxOutEnable ( UseTxOutAddress False )
737
745
, sioLedger = LedgerEnable
738
746
, sioShelley = ShelleyEnable
739
747
, sioRewards = RewardsConfig True
@@ -745,14 +753,13 @@ fullInsertOptions =
745
753
, sioPoolStats = PoolStatsConfig True
746
754
, sioJsonType = JsonTypeText
747
755
, sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
748
- , sioTxOutTableType = TxOutTableTypeConfig False
749
756
}
750
757
751
758
onlyUTxOInsertOptions :: SyncInsertOptions
752
759
onlyUTxOInsertOptions =
753
760
SyncInsertOptions
754
761
{ sioTxCBOR = TxCBORConfig False
755
- , sioTxOut = TxOutBootstrap (ForceTxIn False )
762
+ , sioTxOut = TxOutConsumedBootstrap (ForceTxIn False ) ( UseTxOutAddress False )
756
763
, sioLedger = LedgerIgnore
757
764
, sioShelley = ShelleyDisable
758
765
, sioRewards = RewardsConfig True
@@ -764,7 +771,6 @@ onlyUTxOInsertOptions =
764
771
, sioPoolStats = PoolStatsConfig False
765
772
, sioJsonType = JsonTypeText
766
773
, sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
767
- , sioTxOutTableType = TxOutTableTypeConfig False
768
774
}
769
775
770
776
onlyGovInsertOptions :: SyncInsertOptions
@@ -791,16 +797,15 @@ disableAllInsertOptions =
791
797
, sioGovernance = GovernanceConfig False
792
798
, sioJsonType = JsonTypeText
793
799
, sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
794
- , sioTxOutTableType = TxOutTableTypeConfig False
795
800
}
796
801
797
802
addressTypeToEnableDisable :: IsString s => TxOutTableType -> s
798
- addressTypeToEnableDisable TxOutVariant = " enable"
803
+ addressTypeToEnableDisable TxOutVariantAddress = " enable"
799
804
addressTypeToEnableDisable TxOutCore = " disable"
800
805
801
806
enableDisableToTxOutTableType :: (Eq s , IsString s ) => s -> Maybe TxOutTableType
802
807
enableDisableToTxOutTableType = \ case
803
- " enable" -> Just TxOutVariant
808
+ " enable" -> Just TxOutVariantAddress
804
809
" disable" -> Just TxOutCore
805
810
_ -> Nothing
806
811
0 commit comments