1010
1111{-# OPTIONS_GHC -Wno-noncanonical-monoid-instances #-}
1212
13+ {- HLINT ignore "Functor law" -}
14+
1315module Cardano.Node.Configuration.POM
1416 ( NodeConfiguration (.. )
1517 , ResponderCoreAffinityPolicy (.. )
@@ -35,6 +37,8 @@ import Cardano.Node.Configuration.Socket (SocketConfig (..))
3537import Cardano.Node.Handlers.Shutdown
3638import Cardano.Node.Protocol.Types (Protocol (.. ))
3739import Cardano.Node.Types
40+ import Cardano.Rpc.Server.Config (PartialRpcConfig , RpcConfig , RpcConfigF (.. ),
41+ makeRpcConfig )
3842import Cardano.Tracing.Config
3943import Cardano.Tracing.OrphanInstances.Network ()
4044import qualified Ouroboros.Cardano.Network.Diffusion.Configuration as Cardano
@@ -202,6 +206,9 @@ data NodeConfiguration
202206 , ncGenesisConfig :: GenesisConfig
203207
204208 , ncResponderCoreAffinityPolicy :: ResponderCoreAffinityPolicy
209+
210+ -- gRPC
211+ , ncRpcConfig :: RpcConfig
205212 } deriving (Eq , Show )
206213
207214-- | 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
@@ -418,6 +428,12 @@ instance FromJSON PartialNodeConfiguration where
418428 <$> v .:? " ResponderCoreAffinityPolicy"
419429 <*> v .:? " ForkPolicy" -- deprecated
420430
431+ pncRpcConfig <-
432+ RpcConfig
433+ <$> (Last <$> v .:? " EnableRpc" )
434+ <*> (Last <$> v .:? " RpcSocketPath" )
435+ <*> pure mempty
436+
421437 pure PartialNodeConfiguration {
422438 pncProtocolConfig
423439 , pncSocketConfig = Last . Just $ SocketConfig mempty mempty mempty pncSocketPath
@@ -463,6 +479,7 @@ instance FromJSON PartialNodeConfiguration where
463479 , pncPeerSharing
464480 , pncGenesisConfigFlags
465481 , pncResponderCoreAffinityPolicy
482+ , pncRpcConfig
466483 }
467484 where
468485 parseMempoolCapacityBytesOverride v = parseNoOverride <|> parseOverride
@@ -710,6 +727,7 @@ defaultPartialNodeConfiguration =
710727 , pncGenesisConfigFlags = Last (Just defaultGenesisConfigFlags)
711728 -- https://ouroboros-consensus.cardano.intersectmbo.org/haddocks/ouroboros-consensus-diffusion/Ouroboros-Consensus-Node-Genesis.html#v:defaultGenesisConfigFlags
712729 , pncResponderCoreAffinityPolicy = Last $ Just NoResponderCoreAffinity
730+ , pncRpcConfig = mempty
713731 }
714732
715733lastOption :: Parser a -> Parser (Last a )
@@ -850,6 +868,9 @@ makeNodeConfiguration pnc = do
850868 experimentalProtocols <-
851869 lastToEither " Missing ExperimentalProtocolsEnabled" $
852870 pncExperimentalProtocolsEnabled pnc
871+
872+ ncRpcConfig <- makeRpcConfig $ (pncRpcConfig pnc){nodeSocketPath= ncSocketPath socketConfig}
873+
853874 return $ NodeConfiguration
854875 { ncConfigFile = configFile
855876 , 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