Skip to content

Commit 4334fbe

Browse files
iohk-bors[bot]coot
andauthored
Merge #4363
4363: coot/small changes r=coot a=coot - Removed runRunCommand - Parsing of non-p2p topology file - Remove unfinished handlePeersListSimple Co-authored-by: Marcin Szamotulski <[email protected]>
2 parents a47a954 + fccd10a commit 4334fbe

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

cardano-node/app/cardano-node.hs

+1-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ main = toplevelExceptionHandler $ do
2929
cmd <- Opt.customExecParser p opts
3030

3131
case cmd of
32-
RunCmd args -> runRunCommand args
32+
RunCmd args -> runNode args
3333
TraceDocumentation tdc -> runTraceDocumentationCmd tdc
3434
VersionCmd -> runVersionCommand
3535

@@ -95,9 +95,6 @@ runVersionCommand =
9595
renderVersion = Text.pack . showVersion
9696

9797

98-
runRunCommand :: PartialNodeConfiguration -> IO ()
99-
runRunCommand pnc = liftIO $ runNode pnc
100-
10198
command' :: String -> String -> Parser a -> Mod CommandFields a
10299
command' c descr p =
103100
command c $ info (p <**> helper)

cardano-node/src/Cardano/Node/Configuration/Topology.hs

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module Cardano.Node.Configuration.Topology
1010
, RemoteAddress(..)
1111
, nodeAddressToSockAddr
1212
, readTopologyFile
13+
, readTopologyFileOrError
1314
, remoteAddressToNodeAddress
1415
)
1516
where
@@ -147,3 +148,10 @@ readTopologyFile nc = do
147148
\If you specified the correct topology file \
148149
\make sure that you correctly setup EnableP2P \
149150
\configuration flag. " <> Text.pack err
151+
152+
readTopologyFileOrError :: NodeConfiguration -> IO NetworkTopology
153+
readTopologyFileOrError nc =
154+
readTopologyFile nc
155+
>>= either (\err -> panic $ "Cardano.Node.Configuration.Topology.readTopologyFile: "
156+
<> err)
157+
pure

cardano-node/src/Cardano/Node/Configuration/TopologyP2P.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,6 @@ readTopologyFile nc = do
217217
readTopologyFileOrError :: NodeConfiguration -> IO NetworkTopology
218218
readTopologyFileOrError nc =
219219
readTopologyFile nc
220-
>>= either (\err -> panic $ "Cardano.Node.Run.handleSimpleNodeP2P.readTopologyFile: "
220+
>>= either (\err -> panic $ "Cardano.Node.Configuration.TopologyP2P.readTopologyFile: "
221221
<> err)
222222
pure

cardano-node/src/Cardano/Node/Run.hs

+15-16
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ module Cardano.Node.Run
2020

2121
import Cardano.Prelude hiding (ByteString, STM, atomically, show, take, trace)
2222
import Data.IP (toSockAddr)
23-
import Prelude (String, error, id, show)
23+
import Prelude (String, id, show)
2424

25-
import qualified Control.Concurrent.Async as Async
2625
import Control.Monad.Class.MonadSTM.Strict
2726
import Control.Monad.Trans.Except.Extra (left)
2827
import "contra-tracer" Control.Tracer
@@ -100,7 +99,6 @@ import Cardano.Node.Protocol (mkConsensusProtocol)
10099
import Cardano.Node.Protocol.Types
101100
import Cardano.Node.Queries
102101
import Cardano.Node.TraceConstraints (TraceConstraints)
103-
import Cardano.Tracing.Peer
104102
import Cardano.Tracing.Tracers
105103

106104
{- HLINT ignore "Use fewer imports" -}
@@ -243,17 +241,16 @@ handleNodeWithTracers cmdPc nc p networkMagic runP = do
243241
getStartupInfo nc p fp
244242
>>= mapM_ (traceWith $ startupTracer tracers)
245243

246-
Async.withAsync (handlePeersListSimple (error "Implement Tracer IO [Peer blk]") nodeKernelData)
247-
$ \_peerLoggingThread ->
248-
-- We ignore peer logging thread if it dies, but it will be killed
249-
-- when 'handleSimpleNode' terminates.
250-
handleSimpleNode runP p2pMode tracers nc
251-
(\nk -> do
252-
setNodeKernel nodeKernelData nk
253-
traceWith (nodeStateTracer tracers) NodeKernelOnline)
254-
`finally`
255-
forM_ eLoggingLayer
256-
shutdownLoggingLayer
244+
-- We ignore peer logging thread if it dies, but it will be killed
245+
-- when 'handleSimpleNode' terminates.
246+
handleSimpleNode runP p2pMode tracers nc
247+
(\nk -> do
248+
setNodeKernel nodeKernelData nk
249+
traceWith (nodeStateTracer tracers) NodeKernelOnline)
250+
`finally` do
251+
putStrLn ("MAIN THREAD FAILED" :: String)
252+
forM_ eLoggingLayer
253+
shutdownLoggingLayer
257254

258255
-- | Currently, we trace only 'ShelleyBased'-info which will be asked
259256
-- by 'cardano-tracer' service as a datapoint. It can be extended in the future.
@@ -297,13 +294,16 @@ setupTrace loggingLayer = do
297294
hn0 <- pack <$> getHostName
298295
return $ take 8 $ fst $ breakOn "." hn0
299296

297+
{-
298+
-- TODO: needs to be finished (issue #4362)
300299
handlePeersListSimple
301300
:: Trace IO Text
302301
-> NodeKernelData blk
303302
-> IO ()
304303
handlePeersListSimple tr nodeKern = forever $ do
305304
getCurrentPeers nodeKern >>= tracePeers tr
306305
threadDelay 2000000 -- 2 seconds.
306+
-}
307307

308308
-- | Sets up a simple node, which will run the chain sync protocol and block
309309
-- fetch protocol, and, if core, will also look at the mempool when trying to
@@ -451,8 +451,7 @@ handleSimpleNode runP p2pMode tracers nc onKernel = do
451451
)
452452
Nothing
453453
#endif
454-
eitherTopology <- TopologyNonP2P.readTopologyFile nc
455-
nt <- either (\err -> panic $ "Cardano.Node.Run.handleSimpleNodeNonP2P.readTopologyFile: " <> err) pure eitherTopology
454+
nt <- TopologyNonP2P.readTopologyFileOrError nc
456455
let (ipProducerAddrs, dnsProducerAddrs) = producerAddressesNonP2P nt
457456

458457
dnsProducers :: [DnsSubscriptionTarget]

0 commit comments

Comments
 (0)