From 48b514c650b70afc49f5faa6d9b596ebf666c7de Mon Sep 17 00:00:00 2001 From: Fraser Murray Date: Wed, 15 Jan 2025 13:18:42 +0000 Subject: [PATCH] add MsgGetMeasures / MsgReplyGetMeasures to LocalTxMonitor.Client --- .../Network/Protocol/LocalTxMonitor/Client.hs | 10 ++++++++++ .../Network/Protocol/LocalTxMonitor/Direct.hs | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxMonitor/Client.hs b/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxMonitor/Client.hs index b3efd2ad4a4..647b81d813f 100644 --- a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxMonitor/Client.hs +++ b/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxMonitor/Client.hs @@ -91,6 +91,11 @@ data ClientStAcquired txid tx slot m a where :: (MempoolSizeAndCapacity -> m (ClientStAcquired txid tx slot m a)) -> ClientStAcquired txid tx slot m a + -- | Ask the server about the current mempool's measures + SendMsgGetMeasures + :: (MempoolMeasures -> m (ClientStAcquired txid tx slot m a)) + -> ClientStAcquired txid tx slot m a + -- | Await for a new snapshot and acquire it. -- SendMsgAwaitAcquire @@ -145,6 +150,11 @@ localTxMonitorClientPeer (LocalTxMonitorClient mClient) = Await $ \case MsgReplyGetSizes sizes -> Effect $ handleStAcquired <$> stAcquired sizes + SendMsgGetMeasures stAcquired -> + Yield MsgGetMeasures $ + Await $ \case + MsgReplyGetMeasures measures -> + Effect $ handleStAcquired <$> stAcquired measures SendMsgAwaitAcquire stAcquired -> Yield MsgAwaitAcquire $ Await $ \case diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalTxMonitor/Direct.hs b/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalTxMonitor/Direct.hs index 528f9983e98..5722acad71c 100644 --- a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalTxMonitor/Direct.hs +++ b/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalTxMonitor/Direct.hs @@ -47,6 +47,7 @@ direct (LocalTxMonitorClient mClient) (LocalTxMonitorServer mServer) = do , recvMsgNextTx , recvMsgHasTx , recvMsgGetSizes + , recvMsgGetMeasures } = \case SendMsgRelease mClientStIdle -> do serverStIdle <- recvMsgRelease @@ -71,3 +72,8 @@ direct (LocalTxMonitorClient mClient) (LocalTxMonitorServer mServer) = do SendMsgReplyGetSizes result serverStAcquired -> do clientStAcquired <- mClientStAcquired result directAcquired serverStAcquired clientStAcquired + SendMsgGetMeasures mClientStAcquired -> do + recvMsgGetMeasures >>= \case + SendMsgReplyGetMeasures result serverStAcquired -> do + clientStAcquired <- mClientStAcquired result + directAcquired serverStAcquired clientStAcquired