Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 772e701

Browse files
committed
fixes after rebase conflicts
1 parent f4e5b30 commit 772e701

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

src/exec/DB.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import Ouroboros.Consensus.Ledger.Byron.Config (pbftEpochSlots)
2424
import Ouroboros.Consensus.Ledger.Extended (ExtLedgerState)
2525
import Ouroboros.Consensus.Node (withChainDB)
2626
import Ouroboros.Consensus.Util.ResourceRegistry (ResourceRegistry)
27+
import qualified Ouroboros.Consensus.Util.ResourceRegistry as ResourceRegistry
2728
import Ouroboros.Consensus.Protocol (NodeConfig,
2829
pbftExtConfig)
2930
import Ouroboros.Consensus.Protocol.Abstract (protocolSecurityParam)
@@ -61,7 +62,8 @@ withDB dbOptions dbTracer indexTracer rr btime nodeConfig extLedgerState k = do
6162
withChainDB dbTracer rr btime (dbFilePath dbOptions) nodeConfig extLedgerState customiseArgs
6263
$ \cdb ->
6364
Sqlite.withIndexAuto epochSlots indexTracer (indexFilePath dbOptions) $ \idx -> do
64-
Index.trackChainDB rr idx cdb (protocolSecurityParam nodeConfig) (k idx cdb)
65+
_ <- ResourceRegistry.forkLinkedThread rr $ Index.trackChainDB rr idx cdb (protocolSecurityParam nodeConfig)
66+
k idx cdb
6567

6668
where
6769

src/exec/Main.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ import qualified Pos.Infra.Network.CLI as CSL (NetworkConfigOpts (..),
5555
launchStaticConfigMonitoring,
5656
listenNetworkAddressOption)
5757
import Pos.Infra.Network.Types (NetworkConfig (..))
58-
import qualified Pos.Infra.Network.Policy as Policy
5958
import qualified Pos.Launcher.Configuration as CSL (Configuration (..),
6059
ConfigurationOptions (..))
6160
import qualified Pos.Client.CLI.Options as CSL (configurationOptionsParser)
@@ -497,7 +496,7 @@ runByron tracer byronOptions genesisConfig blockConfig updateConfig nodeConfig e
497496
blockConfig
498497
updateConfig
499498
nodeConfig
500-
networkConfig'
499+
networkConfig
501500
64 -- Batch size.
502501
trace
503502
genesisBlock = CSL.genesisBlock0 (CSL.configProtocolMagic genesisConfig)

src/lib/Ouroboros/Byron/Proxy/Index/ChainDB.hs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ module Ouroboros.Byron.Proxy.Index.ChainDB
55
( trackChainDB
66
) where
77

8-
import Control.Concurrent.Async (race)
98
import Control.Exception (bracket)
109
import 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).
7064
trackChainDB
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

Comments
 (0)