From 826b6a933f7f2a9d8177c2b33e85a8c4395ba896 Mon Sep 17 00:00:00 2001 From: voidlizard Date: Sat, 7 Dec 2024 12:04:32 +0300 Subject: [PATCH] wip31 --- hbs2-git3/app/Main.hs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/hbs2-git3/app/Main.hs b/hbs2-git3/app/Main.hs index 6de15ee7..6ea7fc30 100644 --- a/hbs2-git3/app/Main.hs +++ b/hbs2-git3/app/Main.hs @@ -1272,6 +1272,42 @@ theDict = do pure () + entry $ bindMatch "test:git:cblock:size:deep" $ nil_ $ \case + [ HashLike cblock ] -> lift do + + sto <- getStorage + + _s <- newTVarIO 0 + + deepScan ScanDeep + (\_ -> throwIO MissedBlockError) + (coerce cblock) + (liftIO . getBlock sto) + $ \h -> do + blk <- hasBlock sto h <&> fromMaybe 0 + atomically $ modifyTVar _s (+ blk) + + s <- readTVarIO _s + notice $ pretty s + + _ -> throwIO (BadFormException @C nil) + + entry $ bindMatch "test:git:cblock:blocks:all" $ nil_ $ \case + [ HashLike cblock ] -> lift do + + sto <- getStorage + + blkz <- S.toList_ $ deepScan ScanDeep + (\_ -> throwIO MissedBlockError) + (coerce cblock) + (liftIO . getBlock sto) + S.yield + for_ blkz $ \b -> do + s <- fromMaybe 0 <$> hasBlock sto b + notice $ pretty b <+> pretty s + + _ -> throwIO (BadFormException @C nil) + entry $ bindMatch "test:git:cblock:scan" $ nil_ $ \case [ HashLike cblock ] -> lift do