Skip to content

Commit 02044e1

Browse files
committed
Change signature of opwHasObject to use STM m instead of m
1 parent de3deab commit 02044e1

File tree

4 files changed

+5
-9
lines changed
  • ouroboros-consensus
    • src/ouroboros-consensus/Ouroboros/Consensus/MiniProtocol/ObjectDiffusion
    • test/consensus-test/Test/Consensus/MiniProtocol/ObjectDiffusion

4 files changed

+5
-9
lines changed

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/MiniProtocol/ObjectDiffusion/Inbound.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ objectDiffusionInbound tracer (maxFifoLength, maxNumIdsToReq, maxNumObjectsToReq
287287
-- objectIds that we already have in the pool and thus don't need to
288288
-- request.
289289
let st' = st{numIdsInFlight = numIdsInFlight st - numIdsRequested}
290-
poolHasObject <- opwHasObject
290+
poolHasObject <- atomically $ opwHasObject
291291
continueWithStateM
292292
(go n)
293293
(preAcknowledge st' poolHasObject collectedIds)

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/MiniProtocol/ObjectDiffusion/ObjectPool/API.hs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ data ObjectPoolReader objectId object ticketNo m
1919
-- than the specified one. The number of returned objects is capped by the
2020
-- given Word64. Only the IDs and ticketNos of the objects are directly
2121
-- accessible; each actual object must be loaded through a monadic action.
22-
--
23-
-- TODO: This signature assume that we have all the IDs and ticketNos in
24-
-- memory, but not the actual objects. This might change if IDs must be loaded
25-
-- from disk too.
2622
}
2723

2824
-- | Interface used by the inbound side of object diffusion when receiving
@@ -33,6 +29,6 @@ data ObjectPoolWriter objectId object m
3329
-- ^ Return the id of the specified object
3430
, opwAddObjects :: [object] -> m ()
3531
-- ^ Add a batch of objects to the objectPool.
36-
, opwHasObject :: m (objectId -> Bool)
32+
, opwHasObject :: STM m (objectId -> Bool)
3733
-- ^ Check if the object pool contains an object with the given id
3834
}

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/MiniProtocol/ObjectDiffusion/ObjectPool/PerasCert.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ makePerasCertPoolWriterFromCertDB perasCertDB =
5252
, opwAddObjects =
5353
mapM_ $ PerasCertDB.addCert perasCertDB
5454
, opwHasObject = do
55-
certSnapshot <- atomically $ PerasCertDB.getCertSnapshot perasCertDB
55+
certSnapshot <- PerasCertDB.getCertSnapshot perasCertDB
5656
pure $ PerasCertDB.containsCert certSnapshot
5757
}
5858

@@ -71,6 +71,6 @@ makePerasCertPoolWriterFromChainDB chainDB =
7171
, opwAddObjects =
7272
mapM_ $ ChainDB.addPerasCertAsync chainDB
7373
, opwHasObject = do
74-
certSnapshot <- atomically $ ChainDB.getPerasCertSnapshot chainDB
74+
certSnapshot <- ChainDB.getPerasCertSnapshot chainDB
7575
pure $ PerasCertDB.containsCert certSnapshot
7676
}

ouroboros-consensus/test/consensus-test/Test/Consensus/MiniProtocol/ObjectDiffusion/Smoke.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ makeObjectPoolWriter (SmokeObjectPool poolContentTvar) =
139139
atomically $ modifyTVar poolContentTvar (++ objects)
140140
return ()
141141
, opwHasObject = do
142-
poolContent <- atomically $ readTVar poolContentTvar
142+
poolContent <- readTVar poolContentTvar
143143
pure $ \objectId -> any (\obj -> getSmokeObjectId obj == objectId) poolContent
144144
}
145145

0 commit comments

Comments
 (0)