mirror of https://github.com/voidlizard/hbs2
wip, cli refchan head get - minor opt
This commit is contained in:
parent
92d5524a97
commit
599310a183
|
@ -103,17 +103,12 @@ readBlob hr = do
|
||||||
sto <- getStorage
|
sto <- getStorage
|
||||||
let readBlock h = liftIO $ getBlock sto h
|
let readBlock h = liftIO $ getBlock sto h
|
||||||
|
|
||||||
let mfo acc el = case (acc, el) of
|
chunks <- S.toList_ $
|
||||||
(Nothing, Just s) -> Just [s]
|
|
||||||
(_, Nothing) -> Nothing
|
|
||||||
(Just ss, Just s) -> Just (s:ss)
|
|
||||||
|
|
||||||
chunks <- S.fold_ mfo Nothing id $
|
|
||||||
deepScan ScanDeep (const $ S.yield Nothing) (fromHashRef hr) readBlock $ \ha -> do
|
deepScan ScanDeep (const $ S.yield Nothing) (fromHashRef hr) readBlock $ \ha -> do
|
||||||
unless (fromHashRef hr == ha) do
|
unless (fromHashRef hr == ha) do
|
||||||
readBlock ha >>= S.yield
|
readBlock ha >>= S.yield
|
||||||
|
|
||||||
pure $ LBS.concat . reverse <$> chunks
|
pure $ LBS.concat <$> sequence chunks
|
||||||
|
|
||||||
refChanWorker :: forall e s m . ( MonadIO m
|
refChanWorker :: forall e s m . ( MonadIO m
|
||||||
, MonadUnliftIO m
|
, MonadUnliftIO m
|
||||||
|
|
Loading…
Reference in New Issue