mirror of https://github.com/voidlizard/hbs2
31 lines
644 B
Haskell
31 lines
644 B
Haskell
module Fetch where
|
|
|
|
import HBS2.Prelude
|
|
import HBS2.Actors.Peer
|
|
import HBS2.Data.Types.Refs
|
|
import HBS2.Storage.Operations.Missed
|
|
import HBS2.Net.Proto.Types
|
|
|
|
import PeerTypes
|
|
import BlockDownload
|
|
|
|
import Data.Foldable (for_)
|
|
|
|
fetchHash :: forall e m . (e ~ L4Proto, MonadIO m)
|
|
=> PeerEnv e
|
|
-> DownloadEnv e
|
|
-> HashRef
|
|
-> m ()
|
|
|
|
fetchHash penv denv href = do
|
|
debug $ "fetchAction" <+> pretty h
|
|
liftIO $ withPeerM penv $ do
|
|
sto <- getStorage
|
|
missed <- findMissedBlocks sto href
|
|
for_ missed $ \miss -> do
|
|
withDownload denv (addDownload Nothing (fromHashRef miss))
|
|
|
|
where
|
|
h = fromHashRef href
|
|
|