From c1ea68bb1bdc5ff2f0bbe24685bd6cd4f988099e Mon Sep 17 00:00:00 2001 From: Dmitry Zuikov Date: Fri, 14 Jul 2023 20:38:11 +0300 Subject: [PATCH] wip, cli refchan head get - minor opt --- hbs2-peer/app/RefChan.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hbs2-peer/app/RefChan.hs b/hbs2-peer/app/RefChan.hs index 1c5defda..58e661bf 100644 --- a/hbs2-peer/app/RefChan.hs +++ b/hbs2-peer/app/RefChan.hs @@ -103,17 +103,17 @@ readBlob hr = do sto <- getStorage let readBlock h = liftIO $ getBlock sto h - chunks <- S.toList_ $ - deepScan ScanDeep (const $ S.yield Nothing) (fromHashRef hr) readBlock $ \ha -> do - unless (fromHashRef hr == ha) do - readBlock ha >>= S.yield - let mfo acc el = case (acc, el) of (Nothing, Just s) -> Just [s] (_, Nothing) -> Nothing (Just ss, Just s) -> Just (s:ss) - pure $ LBS.concat . reverse <$> foldl mfo Nothing chunks + chunks <- S.fold_ mfo Nothing id $ + deepScan ScanDeep (const $ S.yield Nothing) (fromHashRef hr) readBlock $ \ha -> do + unless (fromHashRef hr == ha) do + readBlock ha >>= S.yield + + pure $ LBS.concat . reverse <$> chunks refChanWorker :: forall e s m . ( MonadIO m , MonadUnliftIO m