From c97366d58bfa46ecee7fd655a0e959c34d1a35e3 Mon Sep 17 00:00:00 2001 From: chessai Date: Wed, 14 Feb 2024 16:32:27 -0600 Subject: [PATCH] getLatestPactStateAt: exclude tables created after the particular blockheight (#1821) Change-Id: I1b6d2e1f53b10bd5578fdbee1a6bcd17d5bfd095 --- src/Chainweb/Pact/Backend/PactState.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Chainweb/Pact/Backend/PactState.hs b/src/Chainweb/Pact/Backend/PactState.hs index 9ded7052ea..5d9fd03481 100644 --- a/src/Chainweb/Pact/Backend/PactState.hs +++ b/src/Chainweb/Pact/Backend/PactState.hs @@ -236,8 +236,15 @@ getLatestPactStateAt db bh = do tables <- liftIO $ getPactTableNames db + tablesCreatedAfter <- liftIO $ do + let qryText = "SELECT tablename FROM VersionedTableCreation WHERE createBlockheight > ?1" + rows <- Pact.qry db qryText [SInt (int bh)] [RText] + forM rows $ \case + [SText tbl] -> pure tbl + _ -> error "getLatestPactStateAt.tablesCreatedAfter: expected text" + forM_ tables $ \tbl -> do - when (tbl `notElem` excludedTables) $ do + when (tbl `notElem` (excludedTables ++ tablesCreatedAfter)) $ do let qryText = "SELECT rowkey, rowdata, txid FROM " <> "\"" <> tbl <> "\"" <> " WHERE txid