From 847b60ae7eb2d98576ed7e8775a690041fed8081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Thu, 29 May 2025 22:30:40 +0200 Subject: Use weak refs in discovery service --- main/Main.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'main/Main.hs') diff --git a/main/Main.hs b/main/Main.hs index a0c28f7..e9c0ae4 100644 --- a/main/Main.hs +++ b/main/Main.hs @@ -924,13 +924,12 @@ cmdDiscoveryInit = void $ do cmdDiscovery :: Command cmdDiscovery = void $ do Just peer <- gets csIcePeer - 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 + case readRefDigest (BC.pack sref) of + Nothing -> throwOtherError "failed to parse ref" + Just dgst -> liftIO $ do + res <- runExceptT $ sendToPeer peer $ DiscoverySearch $ Right dgst case res of Right _ -> return () Left err -> eprint err -- cgit v1.2.3