summaryrefslogtreecommitdiff
path: root/src/Network.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2022-07-28 21:29:37 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2022-07-28 21:29:37 +0200
commitba50676a1fe66c5f24f251984f2cb49c0e98aead (patch)
tree3b1b9a98d3df18c7fb197090c3b954cb168372ff /src/Network.hs
parent9615085b1427efe616302af4e9887f7cb84a9a0c (diff)
Service: wait with output after head commit
Diffstat (limited to 'src/Network.hs')
-rw-r--r--src/Network.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/Network.hs b/src/Network.hs
index 7195129..3cf714d 100644
--- a/src/Network.hs
+++ b/src/Network.hs
@@ -835,10 +835,12 @@ sendToPeerList :: (Service s, MonadIO m) => Peer -> [ServiceReply s] -> m ()
sendToPeerList peer parts = do
let st = peerStorage peer
pst = peerInStorage peer
- srefs <- liftIO $ forM parts $ \case ServiceReply (Left x) _ -> store st x
- ServiceReply (Right sx) _ -> return $ storedRef sx
- prefs <- mapM (copyRef pst) srefs
- let content = map snd $ filter (\(ServiceReply _ use, _) -> use) (zip parts srefs)
+ srefs <- liftIO $ fmap catMaybes $ forM parts $ \case
+ ServiceReply (Left x) use -> Just . (,use) <$> store st x
+ ServiceReply (Right sx) use -> return $ Just (storedRef sx, use)
+ ServiceFinally act -> act >> return Nothing
+ prefs <- mapM (copyRef pst . fst) srefs
+ let content = map fst $ filter snd srefs
header = TransportHeader (ServiceType (serviceID $ head parts) : map ServiceRef prefs)
packet = TransportPacket header content
ackedBy = concat [[ Acknowledged r, Rejected r, DataRequest r ] | r <- prefs ]