mirror of https://github.com/voidlizard/hbs2
wip, tryin to fetch refchan head
This commit is contained in:
parent
8e567c87d0
commit
3e65c4b7b7
|
@ -95,18 +95,18 @@ refChanAddDownload env chan r = do
|
|||
|
||||
atomically $ modifyTVar (view refChanWorkerEnvDownload env) (HashMap.insert r (chan,t))
|
||||
|
||||
-- FIXME: slow-deep-scan-exception-seems-not-working
|
||||
checkDownloaded :: forall m . (MonadIO m, HasStorage m, Block ByteString ~ ByteString) => HashRef -> m Bool
|
||||
checkDownloaded hr = do
|
||||
sto <- getStorage
|
||||
let readBlock h = liftIO $ getBlock sto h
|
||||
|
||||
result <- runExceptT $
|
||||
deepScan ScanDeep (const $ throwError DataNotReady) (fromHashRef hr) readBlock $ \ha -> do
|
||||
here <- liftIO $ hasBlock sto ha <&> isJust
|
||||
unless here $ throwError DataNotReady
|
||||
|
||||
pure $ either (const False) (const True) result
|
||||
result <- S.toList_ $
|
||||
deepScan ScanDeep (const $ S.yield Nothing) (fromHashRef hr) readBlock $ \ha -> do
|
||||
here <- liftIO $ hasBlock sto ha
|
||||
S.yield here
|
||||
|
||||
pure $ isJust $ sequence result
|
||||
|
||||
-- FIXME: move-to-library
|
||||
readBlob :: forall m . ( MonadIO m
|
||||
|
|
Loading…
Reference in New Issue