Skip to content

Commit 66757c9

Browse files
committed
documentation for keep-tx-metadata flag
1 parent a9b6eee commit 66757c9

File tree

5 files changed

+48
-12
lines changed

5 files changed

+48
-12
lines changed

cardano-db-sync/app/cardano-db-sync.hs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Cardano.DbSync.Config
77
import Cardano.DbSync.Metrics (withMetricSetters)
88
import Cardano.Prelude
99
import Cardano.Slotting.Slot (SlotNo (..))
10+
import Data.List.Split (splitOn)
1011
import Data.String (String)
1112
import qualified Data.Text as Text
1213
import Data.Version (showVersion)
@@ -231,13 +232,17 @@ pSlotNo =
231232

232233
pKeepTxMetadata :: Parser [Word64]
233234
pKeepTxMetadata =
234-
Opt.many
235-
( Opt.option
236-
Opt.auto
237-
( Opt.long "keep-tx-metadata"
238-
<> Opt.help "Insert a specific set of tx metadata, based on the tx metadata key names"
239-
)
235+
Opt.option
236+
(parseCommaSeparated <$> Opt.str)
237+
( Opt.long "keep-tx-metadata"
238+
<> Opt.help "Insert a specific set of tx metadata, based on the tx metadata key names"
240239
)
240+
where
241+
parseCommaSeparated :: String -> [Word64]
242+
parseCommaSeparated str =
243+
case traverse readMaybe (splitOn "," str) of
244+
Just values -> values
245+
Nothing -> error "Failed to parse comma-separated values"
241246

242247
pHasInOut :: Parser Bool
243248
pHasInOut =

cardano-db-sync/cardano-db-sync.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ executable cardano-db-sync
254254
, cardano-prelude
255255
, cardano-slotting
256256
, optparse-applicative
257+
, split
257258
, text
258259

259260
executable http-get-json-metadata

cardano-db-sync/src/Cardano/DbSync.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,13 @@ extractSyncOptions snp aop =
235235
where
236236
maybeKeepMNames =
237237
if null (enpKeepMetadataNames snp)
238-
then Strict.Just (enpKeepMetadataNames snp)
239-
else Strict.Nothing
238+
then Strict.Nothing
239+
else Strict.Just (enpKeepMetadataNames snp)
240240

241241
iopts
242242
| enpOnlyGov snp = onlyGovInsertOptions useLedger
243243
| enpOnlyUTxO snp = onlyUTxOInsertOptions
244-
| enpFullMode snp = fullInsertOptions useLedger maybeKeepMNames
244+
| enpFullMode snp = fullInsertOptions useLedger
245245
| enpDisableAllMode snp = disableAllInsertOptions useLedger
246246
| otherwise =
247247
InsertOptions

cardano-db-sync/src/Cardano/DbSync/Api.hs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,20 @@ getPrunes :: SyncEnv -> Bool
199199
getPrunes = do
200200
DB.pcmPruneTxOut . getPruneConsume
201201

202-
fullInsertOptions :: Bool -> Strict.Maybe [Word64] -> InsertOptions
203-
fullInsertOptions useLedger maybeKeepMNames = InsertOptions True useLedger True True True True maybeKeepMNames True True True
202+
fullInsertOptions :: Bool -> InsertOptions
203+
fullInsertOptions useLedger =
204+
InsertOptions
205+
{ ioInOut = True
206+
, ioUseLedger = useLedger
207+
, ioShelley = True
208+
, ioRewards = True
209+
, ioMultiAssets = True
210+
, ioMetadata = True
211+
, ioKeepMetadataNames = Strict.Nothing
212+
, ioPlutusExtra = True
213+
, ioOffChainPoolData = True
214+
, ioGov = True
215+
}
204216

205217
onlyUTxOInsertOptions :: InsertOptions
206218
onlyUTxOInsertOptions =
@@ -221,7 +233,19 @@ onlyGovInsertOptions :: Bool -> InsertOptions
221233
onlyGovInsertOptions useLedger = (disableAllInsertOptions useLedger) {ioGov = True}
222234

223235
disableAllInsertOptions :: Bool -> InsertOptions
224-
disableAllInsertOptions useLedger = InsertOptions False useLedger False False False False Strict.Nothing False False False
236+
disableAllInsertOptions useLedger =
237+
InsertOptions
238+
{ ioInOut = False
239+
, ioUseLedger = useLedger
240+
, ioShelley = False
241+
, ioRewards = False
242+
, ioMultiAssets = False
243+
, ioMetadata = False
244+
, ioKeepMetadataNames = Strict.Nothing
245+
, ioPlutusExtra = False
246+
, ioOffChainPoolData = False
247+
, ioGov = False
248+
}
225249

226250
initEpochState :: EpochState
227251
initEpochState =

doc/configuration.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,9 @@ Some field are left empty when using this flag, like
154154
- `redeemer.script_hash` is left Null
155155

156156
Until the ledger state migration happens any restart requires reusing the `--bootstrap-tx-out` flag. After it's completed the flag can be omitted on restarts.
157+
158+
### --keep-tx-metadata
159+
160+
This flag was introduced in v.13.2.0.0 as all postgres field with the type jsonb were removed to improve insertion performance.
161+
If they are required and you have database queries against jsonb then activate this flag to re-introduce the type jsonb.
162+
You can pass multiple values to the flag eg: `--keep-tx-metadata 1,2,3` make sure you are using commas between each key.

0 commit comments

Comments
 (0)