From 7074fec300cde226677ef1cef951c20dd76edf7e Mon Sep 17 00:00:00 2001 From: Sergey Ivanov Date: Wed, 15 Mar 2023 07:12:54 +0400 Subject: [PATCH] wip --- hbs2-peer/app/PeerMain.hs | 16 ++++++++-------- hbs2-peer/app/RPC.hs | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hbs2-peer/app/PeerMain.hs b/hbs2-peer/app/PeerMain.hs index 87dc04c4..233e71f4 100644 --- a/hbs2-peer/app/PeerMain.hs +++ b/hbs2-peer/app/PeerMain.hs @@ -757,13 +757,13 @@ runPeer opts = Exception.handle myException $ do liftIO $ atomically $ writeTQueue rpcQ (LREFANN h) let lrefGetAction h = do - debug $ "lrefGetAction" <+> pretty h + debug $ "lrefGetAction" <+> pretty h who <- thatPeer (Proxy @(RPC e)) void $ liftIO $ async $ withPeerM penv $ do st <- getStorage - mhval <- getLRefValAction st h - forM_ mhval \hval -> - request who (RPCLRefGetAnswer @e h hval) + hval <- getLRefValAction st h + request who (RPCLRefGetAnswer @e h hval) + debug $ "lrefGetAction sent" <+> pretty h let arpc = RpcAdapter pokeAction @@ -777,7 +777,7 @@ runPeer opts = Exception.handle myException $ do logLevelAction lrefAnnAction lrefGetAction - (\h hval -> pure ()) + dontHandle rpc <- async $ runRPC udp1 do runProto @e @@ -910,7 +910,7 @@ withRPC o cmd = do (const $ liftIO exitSuccess) (const $ liftIO exitSuccess) - (\h hval -> Log.info $ pretty h <+> viaShow hval) + (\(h, hval) -> Log.info $ pretty h <+> viaShow hval) runRpcCommand :: RPCOpt -> RPCCommand -> IO () runRpcCommand opt = \case @@ -920,8 +920,8 @@ runRpcCommand opt = \case FETCH h -> withRPC opt (RPCFetch h) PEERS -> withRPC opt RPCPeers SETLOG s -> withRPC opt (RPCLogLevel s) - LREFANN h -> withRPC opt (RPCLRefAnn h) - LREFGET h -> withRPC opt (RPCLRefGet h) + LREFANN h -> withRPC opt (RPCLRefAnn h) + LREFGET h -> withRPC opt (RPCLRefGet h) _ -> pure () diff --git a/hbs2-peer/app/RPC.hs b/hbs2-peer/app/RPC.hs index ef8dbe2b..c234c742 100644 --- a/hbs2-peer/app/RPC.hs +++ b/hbs2-peer/app/RPC.hs @@ -35,7 +35,7 @@ data RPC e = | RPCLogLevel SetLogging | RPCLRefAnn (Hash HbSync) | RPCLRefGet (Hash HbSync) - | RPCLRefGetAnswer (Hash HbSync) (Signed SignaturePresent (MutableRef e 'LinearRef)) + | RPCLRefGetAnswer (Hash HbSync) (Maybe (Signed 'SignaturePresent (MutableRef e 'LinearRef))) deriving stock (Generic) @@ -72,7 +72,7 @@ data RpcAdapter e m = , rpcOnLogLevel :: SetLogging -> m () , rpcOnLRefAnn :: Hash HbSync -> m () , rpcOnLRefGet :: Hash HbSync -> m () - , rpcOnLRefGetAnswer :: Hash HbSync -> Signed SignaturePresent (MutableRef e 'LinearRef) -> m () + , rpcOnLRefGetAnswer :: (Hash HbSync, Maybe (Signed 'SignaturePresent (MutableRef e 'LinearRef))) -> m () } newtype RpcM m a = RpcM { fromRpcM :: ReaderT RPCEnv m a } @@ -124,5 +124,5 @@ rpcHandler adapter = \case (RPCLogLevel l) -> rpcOnLogLevel adapter l (RPCLRefAnn h) -> rpcOnLRefAnn adapter h (RPCLRefGet h) -> rpcOnLRefGet adapter h - (RPCLRefGetAnswer h hval) -> rpcOnLRefGetAnswer adapter h hval + (RPCLRefGetAnswer h hval) -> rpcOnLRefGetAnswer adapter (h, hval)