From 4d756d6eaf6b72232af48a4f6c00c785dc29e910 Mon Sep 17 00:00:00 2001 From: Dmitry Zuikov Date: Fri, 20 Oct 2023 19:45:40 +0300 Subject: [PATCH] fixed? tcp pex --- hbs2-peer/app/PeerMain.hs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/hbs2-peer/app/PeerMain.hs b/hbs2-peer/app/PeerMain.hs index 793c4f47..af64ab51 100644 --- a/hbs2-peer/app/PeerMain.hs +++ b/hbs2-peer/app/PeerMain.hs @@ -709,14 +709,13 @@ runPeer opts = U.handle (\e -> myException e rcw <- async $ liftIO $ runRefChanRelyWorker rce refChanAdapter let pexFilt pips = do - tcpex <- listTCPPexCandidates @e brains <&> HashSet.fromList - fset <- forM pips $ \p -> do - toPeerAddr p >>= \case - (L4Address UDP _) -> pure $ Just p - pa@(L4Address TCP _) | HashSet.member pa tcpex -> pure $ Just p - _ -> pure Nothing - - pure (catMaybes fset) + tcpex <- listTCPPexCandidates @e brains -- <&> HashSet.fromList + pips2 <- filter onlyUDP <$> mapM toPeerAddr pips + pure (L.nub (pips2 <> tcpex)) + where + onlyUDP = \case + (L4Address UDP _) -> True + _ -> False let onNoBlock (p, h) = do already <- liftIO $ Cache.lookup nbcache (p,h) <&> isJust