Skip to content

Commit

Permalink
ByteSize -> TxMeasure blk in LocalTxMonitor.Server
Browse files Browse the repository at this point in the history
  • Loading branch information
fraser-iohk committed Jul 26, 2024
1 parent 56df6c2 commit 78e25ea
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ localTxMonitorServer mempool =
, recvMsgAcquire = do
s <- atomically $
(,)
<$> (txMeasureByteSize <$> getCapacity mempool)
<$> getCapacity mempool
<*> getSnapshot mempool
pure $ serverStAcquiring s
}

serverStAcquiring
:: (ByteSize, MempoolSnapshot blk)
:: (TxMeasure blk, MempoolSnapshot blk)
-> ServerStAcquiring (GenTxId blk) (GenTx blk) SlotNo m ()
serverStAcquiring s@(_, snapshot) =
SendMsgAcquired (snapshotSlotNo snapshot) (serverStAcquired s (snapshotTxs snapshot))

serverStAcquired
:: (ByteSize, MempoolSnapshot blk)
:: (TxMeasure blk, MempoolSnapshot blk)
-> [(Validated (GenTx blk), idx, TxMeasure blk)]
-> ServerStAcquired (GenTxId blk) (GenTx blk) SlotNo m ()
serverStAcquired s@(capacity, snapshot) txs =
Expand All @@ -61,16 +61,16 @@ localTxMonitorServer mempool =
, recvMsgGetSizes = do
let MempoolSize{msNumTxs,msNumBytes} = snapshotMempoolSize snapshot
let sizes = MempoolSizeAndCapacity
{ capacityInBytes = fromByteSize capacity
, sizeInBytes = fromByteSize msNumBytes
{ capacityInBytes = fromByteSize $ txMeasureByteSize capacity
, sizeInBytes = fromByteSize $ txMeasureByteSize msNumBytes
, numberOfTxs = msNumTxs
} -- TODO what to do about overflow?
pure $ SendMsgReplyGetSizes sizes (serverStAcquired s txs)
, recvMsgAwaitAcquire = do
s' <- atomically $ do
s'@(_, snapshot') <-
(,)
<$> (txMeasureByteSize <$> getCapacity mempool)
<$> getCapacity mempool
<*> getSnapshot mempool
s' <$ check (not (snapshot `isSameSnapshot` snapshot'))
pure $ serverStAcquiring s'
Expand Down

0 comments on commit 78e25ea

Please sign in to comment.