summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/Main.hs9
-rw-r--r--main/Test.hs5
2 files changed, 6 insertions, 8 deletions
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
diff --git a/main/Test.hs b/main/Test.hs
index 44818fd..a119b0f 100644
--- a/main/Test.hs
+++ b/main/Test.hs
@@ -957,11 +957,10 @@ cmdChatroomMessageSend = do
cmdDiscoveryConnect :: Command
cmdDiscoveryConnect = do
- st <- asks tiStorage
[ tref ] <- asks tiParams
- Just ref <- liftIO $ readRef st $ encodeUtf8 tref
+ Just dgst <- return $ readRefDigest $ encodeUtf8 tref
Just RunningServer {..} <- gets tsServer
peers <- liftIO $ getCurrentPeerList rsServer
forM_ peers $ \peer -> do
- sendToPeer peer $ DiscoverySearch ref
+ sendToPeer peer $ DiscoverySearch $ Right dgst