diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2025-06-01 17:39:58 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2025-06-12 20:53:10 +0200 |
commit | e8f3cbe08071c0507abafa76d0bf9d32908bbd7e (patch) | |
tree | 275347fffda7313b81ae3cfffc2df08d5cf20d17 /main | |
parent | 0cc2b3ee83e46608495f4fb92ea8c2ca48b4e306 (diff) |
Discovery search using global state to ask new peers
Diffstat (limited to 'main')
-rw-r--r-- | main/Main.hs | 4 | ||||
-rw-r--r-- | main/Test.hs | 5 |
2 files changed, 3 insertions, 6 deletions
diff --git a/main/Main.hs b/main/Main.hs index e055275..59ea7c3 100644 --- a/main/Main.hs +++ b/main/Main.hs @@ -893,14 +893,14 @@ cmdDiscoveryInit = void $ do cmdDiscovery :: Command cmdDiscovery = void $ do - Just peer <- gets csIcePeer + server <- asks ciServer st <- getStorage sref <- asks ciLine eprint <- asks ciPrint liftIO $ readRef st (BC.pack sref) >>= \case Nothing -> error "ref does not exist" Just ref -> do - res <- runExceptT $ sendToPeer peer $ DiscoverySearch ref + res <- runExceptT $ discoverySearch server ref case res of Right _ -> return () Left err -> eprint err diff --git a/main/Test.hs b/main/Test.hs index 0181575..75eaaaf 100644 --- a/main/Test.hs +++ b/main/Test.hs @@ -880,8 +880,5 @@ cmdDiscoveryConnect = do st <- asks tiStorage [ tref ] <- asks tiParams Just ref <- liftIO $ readRef st $ encodeUtf8 tref - Just RunningServer {..} <- gets tsServer - peers <- liftIO $ getCurrentPeerList rsServer - forM_ peers $ \peer -> do - sendToPeer peer $ DiscoverySearch ref + discoverySearch rsServer ref |