diff --git a/cardano-db/app/Cardano/Db/App/Validate/BlockTxs.hs b/cardano-db/app/Cardano/Db/App/Validate/BlockTxs.hs index 56cff35d2..28f7b2f99 100644 --- a/cardano-db/app/Cardano/Db/App/Validate/BlockTxs.hs +++ b/cardano-db/app/Cardano/Db/App/Validate/BlockTxs.hs @@ -24,10 +24,11 @@ import qualified System.Random as Random validateEpochBlockTxs :: IO () validateEpochBlockTxs = do + fullySynced <- runDbNoLogging queryIsFullySynced mLatestEpoch <- runDbNoLogging queryLatestCachedEpochNo case mLatestEpoch of Nothing -> putStrLn "Epoch table is empty" - Just latest -> validateLatestBlockTxs latest + Just latest -> validateLatestBlockTxs fullySynced latest -- ----------------------------------------------------------------------------- @@ -37,10 +38,15 @@ data ValidateError = ValidateError , veTxCountExpected :: !Word64 } -validateLatestBlockTxs :: Word64 -> IO () -validateLatestBlockTxs latestEpoch = do - validateBlockTxs latestEpoch - validateBlockTxs =<< Random.randomRIO (0, latestEpoch - 1) +validateLatestBlockTxs :: Bool -> Word64 -> IO () +validateLatestBlockTxs fullySynced latestEpoch = do + if not fullySynced + then putStrLn "Not fully synced so not running BlockTx validation" + else do + -- This validation seems to be quite DB intensive, so only run it + -- when the DB is fully synced. + validateBlockTxs latestEpoch + validateBlockTxs =<< Random.randomRIO (0, latestEpoch - 1) validateBlockTxs :: Word64 -> IO () validateBlockTxs epoch = do