Skip to content

Commit

Permalink
remove soptUseLedger as only used during setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Cmdv committed Mar 17, 2023
1 parent 01d6138 commit 8ff33b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
15 changes: 10 additions & 5 deletions cardano-db-sync/src/Cardano/DbSync/Api.hs
Expand Up @@ -149,7 +149,6 @@ data SyncOptions = SyncOptions
{ soptExtended :: !Bool
, soptAbortOnInvalid :: !Bool
, soptCache :: !Bool
, soptUseLedger :: !Bool
, soptSkipFix :: !Bool
, soptOnlyFix :: !Bool
, snapshotEveryFollowing :: !Word64
Expand Down Expand Up @@ -226,7 +225,10 @@ getBackend env = do
Strict.Nothing -> panic "sql connection not initiated"

hasLedgerState :: SyncEnv -> Bool
hasLedgerState = soptUseLedger . envOptions
hasLedgerState syncEnv =
case envLedgerEnv syncEnv of
HasLedger _ -> True
NoLedger _ -> False

getDbLatestBlockInfo :: SqlBackend -> IO (Maybe TipInfo)
getDbLatestBlockInfo backend = do
Expand Down Expand Up @@ -283,11 +285,12 @@ mkSyncEnv ::
NetworkMagic ->
SystemStart ->
Maybe LedgerStateDir ->
Bool -> -- shouldUseLedger
Bool ->
Bool ->
RunMigration ->
IO SyncEnv
mkSyncEnv trce connSring syncOptions protoInfo nw nwMagic systemStart maybeLedgerDir ranAll forcedIndexes runMigration = do
mkSyncEnv trce connSring syncOptions protoInfo nw nwMagic systemStart maybeLedgerDir shouldUseLedger ranAll forcedIndexes runMigration = do
cache <- if soptCache syncOptions then newEmptyCache 250000 else pure uninitiatedCache
backendVar <- newTVarIO Strict.Nothing
consistentLevelVar <- newTVarIO Unchecked
Expand All @@ -298,7 +301,7 @@ mkSyncEnv trce connSring syncOptions protoInfo nw nwMagic systemStart maybeLedge
epochVar <- newTVarIO initEpochState
epochSyncTime <- newTVarIO =<< getCurrentTime
ledgerEnvType <-
case (maybeLedgerDir, soptUseLedger syncOptions) of
case (maybeLedgerDir, shouldUseLedger) of
(Just dir, True) ->
HasLedger
<$> mkHasLedgerEnv
Expand Down Expand Up @@ -339,12 +342,13 @@ mkSyncEnvFromConfig ::
ConnectionString ->
SyncOptions ->
Maybe LedgerStateDir ->
Bool -> -- shouldUseLedger
GenesisConfig ->
Bool ->
Bool ->
RunMigration ->
IO (Either SyncNodeError SyncEnv)
mkSyncEnvFromConfig trce connSring syncOptions maybeLedgerDir genCfg ranAll forcedIndexes runMigration =
mkSyncEnvFromConfig trce connSring syncOptions maybeLedgerDir shouldUseLedger genCfg ranAll forcedIndexes runMigration =
case genCfg of
GenesisCardano _ bCfg sCfg _
| unProtocolMagicId (Byron.configProtocolMagicId bCfg) /= Shelley.sgNetworkMagic (scConfig sCfg) ->
Expand Down Expand Up @@ -374,6 +378,7 @@ mkSyncEnvFromConfig trce connSring syncOptions maybeLedgerDir genCfg ranAll forc
(NetworkMagic . unProtocolMagicId $ Byron.configProtocolMagicId bCfg)
(SystemStart . Byron.gdStartTime $ Byron.configGenesisData bCfg)
maybeLedgerDir
shouldUseLedger
ranAll
forcedIndexes
runMigration
Expand Down
3 changes: 2 additions & 1 deletion cardano-db-sync/src/Cardano/DbSync/Sync.hs
Expand Up @@ -161,18 +161,19 @@ runSyncNode metricsSetters trce iomgr aop snEveryFollowing snEveryLagging dbConn
(enpExtended syncNodeParams)
aop
(enpHasCache syncNodeParams)
(enpShouldUseLedger syncNodeParams)
(enpSkipFix syncNodeParams)
(enpOnlyFix syncNodeParams)
snEveryFollowing
snEveryLagging
)
(enpMaybeLedgerStateDir syncNodeParams)
(enpShouldUseLedger syncNodeParams)
genCfg
ranAll
(enpForceIndexes syncNodeParams)
runMigration


-- If the DB is empty it will be inserted, otherwise it will be validated (to make
-- sure we are on the right chain).
lift $
Expand Down

0 comments on commit 8ff33b9

Please sign in to comment.