@@ -5,7 +5,6 @@ module Ouroboros.Byron.Proxy.Index.ChainDB
55 ( trackChainDB
66 ) where
77
8- import Control.Concurrent.Async (race )
98import Control.Exception (bracket )
109import Data.Word (Word64 )
1110
@@ -54,12 +53,7 @@ trackReader idx reader = do
5453 trackReader idx reader
5554 Nothing -> pure ()
5655
57- -- | Have an Index track a ChainDB using its Reader API for the duration of
58- -- some monadic action.
59- --
60- -- It will spawn a thread to do the index updates. This must be the only
61- -- index writer. It is run by `race` with the action, so exceptions in either
62- -- the action or the writer thread will be re-thrown here.
56+ -- | Have an Index track a ChainDB using its Reader API.
6357--
6458-- If the tip of the index is in the ChainDB, then no work must be done in the
6559-- beginning. But if it's not in the ChainDB, there will have to be a rollback
@@ -68,14 +62,13 @@ trackReader idx reader = do
6862-- ChainDB. If none are in it, then the entire index will be rebuild (rollback
6963-- to Origin).
7064trackChainDB
71- :: forall blk t .
65+ :: forall blk void .
7266 ResourceRegistry IO
7367 -> Index IO (Header blk )
7468 -> ChainDB IO blk
7569 -> SecurityParam
76- -> IO t
77- -> IO t
78- trackChainDB rr idx cdb k act = bracket acquireReader releaseReader $ \ rdr -> do
70+ -> IO void
71+ trackChainDB rr idx cdb k = bracket acquireReader releaseReader $ \ rdr -> do
7972 checkpoints <- Index. streamFromTip idx checkpointsFold
8073 mPoint <- ChainDB. readerForward rdr checkpoints
8174 case mPoint of
@@ -91,10 +84,7 @@ trackChainDB rr idx cdb k act = bracket acquireReader releaseReader $ \rdr -> do
9184 -- First, block until the index is caught up to the tip ...
9285 trackReader idx rdr
9386 -- ... then attempt to stay in sync.
94- outcome <- race (trackReaderBlocking idx rdr) act
95- case outcome of
96- Left impossible -> impossible
97- Right t -> pure t
87+ trackReaderBlocking idx rdr
9888 where
9989 acquireReader :: IO (Reader IO blk (Header blk ))
10090 acquireReader = ChainDB. deserialiseReader <$> ChainDB. newHeaderReader cdb rr
0 commit comments