1010
1111{-# OPTIONS_GHC -Wno-noncanonical-monoid-instances #-}
1212
13+ {- HLINT ignore "Functor law" -}
14+
1315module Cardano.Node.Configuration.POM
1416 ( NodeConfiguration (.. )
1517 , ResponderCoreAffinityPolicy (.. )
@@ -36,6 +38,8 @@ import Cardano.Node.Configuration.Socket (SocketConfig (..))
3638import Cardano.Node.Handlers.Shutdown
3739import Cardano.Node.Protocol.Types (Protocol (.. ))
3840import Cardano.Node.Types
41+ import Cardano.Rpc.Server.Config (PartialRpcConfig , RpcConfig , RpcConfigF (.. ),
42+ makeRpcConfig )
3943import Cardano.Tracing.Config
4044import Cardano.Tracing.OrphanInstances.Network ()
4145import qualified Ouroboros.Cardano.Network.Diffusion.Configuration as Cardano
@@ -203,6 +207,9 @@ data NodeConfiguration
203207 , ncGenesisConfig :: GenesisConfig
204208
205209 , ncResponderCoreAffinityPolicy :: ResponderCoreAffinityPolicy
210+
211+ -- gRPC
212+ , ncRpcConfig :: RpcConfig
206213 } deriving (Eq , Show )
207214
208215-- | We expose the `Ouroboros.Network.Mux.ForkPolicy` as a `NodeConfiguration` field.
@@ -283,13 +290,13 @@ data PartialNodeConfiguration
283290 , pncSyncTargetOfKnownBigLedgerPeers :: ! (Last Int )
284291 , pncSyncTargetOfEstablishedBigLedgerPeers :: ! (Last Int )
285292 , pncSyncTargetOfActiveBigLedgerPeers :: ! (Last Int )
293+ -- Consensus mode for diffusion layer
294+ , pncConsensusMode :: ! (Last ConsensusMode )
295+
286296 -- Minimum number of active big ledger peers we must be connected to
287297 -- in Genesis mode
288298 , pncMinBigLedgerPeersForTrustedState :: ! (Last NumberOfBigLedgerPeers )
289299
290- -- Consensus mode for diffusion layer
291- , pncConsensusMode :: ! (Last ConsensusMode )
292-
293300 -- Network P2P mode
294301 , pncEnableP2P :: ! (Last NetworkP2PMode )
295302
@@ -300,6 +307,9 @@ data PartialNodeConfiguration
300307 , pncGenesisConfigFlags :: ! (Last GenesisConfigFlags )
301308
302309 , pncResponderCoreAffinityPolicy :: ! (Last ResponderCoreAffinityPolicy )
310+
311+ -- gRPC
312+ , pncRpcConfig :: ! PartialRpcConfig
303313 } deriving (Eq , Generic , Show )
304314
305315instance AdjustFilePaths PartialNodeConfiguration where
@@ -417,6 +427,12 @@ instance FromJSON PartialNodeConfiguration where
417427 <$> v .:? " ResponderCoreAffinityPolicy"
418428 <*> v .:? " ForkPolicy" -- deprecated
419429
430+ pncRpcConfig <-
431+ RpcConfig
432+ <$> (Last <$> v .:? " EnableRpc" )
433+ <*> (Last <$> v .:? " RpcSocketPath" )
434+ <*> pure mempty
435+
420436 pure PartialNodeConfiguration {
421437 pncProtocolConfig
422438 , pncSocketConfig = Last . Just $ SocketConfig mempty mempty mempty pncSocketPath
@@ -462,6 +478,7 @@ instance FromJSON PartialNodeConfiguration where
462478 , pncPeerSharing
463479 , pncGenesisConfigFlags
464480 , pncResponderCoreAffinityPolicy
481+ , pncRpcConfig
465482 }
466483 where
467484 parseMempoolCapacityBytesOverride v = parseNoOverride <|> parseOverride
@@ -709,6 +726,7 @@ defaultPartialNodeConfiguration =
709726 , pncGenesisConfigFlags = Last (Just defaultGenesisConfigFlags)
710727 -- https://ouroboros-consensus.cardano.intersectmbo.org/haddocks/ouroboros-consensus-diffusion/Ouroboros-Consensus-Node-Genesis.html#v:defaultGenesisConfigFlags
711728 , pncResponderCoreAffinityPolicy = Last $ Just NoResponderCoreAffinity
729+ , pncRpcConfig = mempty
712730 }
713731
714732lastOption :: Parser a -> Parser (Last a )
@@ -844,6 +862,9 @@ makeNodeConfiguration pnc = do
844862 experimentalProtocols <-
845863 lastToEither " Missing ExperimentalProtocolsEnabled" $
846864 pncExperimentalProtocolsEnabled pnc
865+
866+ ncRpcConfig <- makeRpcConfig $ (pncRpcConfig pnc){nodeSocketPath= ncSocketPath socketConfig}
867+
847868 return $ NodeConfiguration
848869 { ncConfigFile = configFile
849870 , ncTopologyFile = topologyFile
@@ -898,6 +919,7 @@ makeNodeConfiguration pnc = do
898919 , ncConsensusMode
899920 , ncGenesisConfig
900921 , ncResponderCoreAffinityPolicy
922+ , ncRpcConfig
901923 }
902924
903925ncProtocol :: NodeConfiguration -> Protocol
0 commit comments