hbs2/hbs2-peer/app/Fetch.hs

28 lines
536 B
Haskell

module Fetch where
import HBS2.Prelude
import HBS2.Actors.Peer
import HBS2.Data.Types.Refs
import HBS2.Net.Proto.Types
import HBS2.System.Logger.Simple
import PeerTypes
import DownloadQ
import BlockDownload
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
downloadLogAppend @e h
withDownload denv (processBlock h)
where
h = fromHashRef href