1010
1111{-# OPTIONS_GHC -Wno-noncanonical-monoid-instances #-}
1212
13+ {- HLINT ignore "Functor law" -}
14+
1315module Cardano.Node.Configuration.POM
1416 ( NodeConfiguration (.. )
1517 , ResponderCoreAffinityPolicy (.. )
@@ -34,6 +36,8 @@ import Cardano.Node.Configuration.Socket (SocketConfig (..))
3436import Cardano.Node.Handlers.Shutdown
3537import Cardano.Node.Protocol.Types (Protocol (.. ))
3638import Cardano.Node.Types
39+ import Cardano.Rpc.Server.Config (PartialRpcConfig , RpcConfig , RpcConfigF (.. ),
40+ makeRpcConfig )
3741import Cardano.Tracing.Config
3842import Cardano.Tracing.OrphanInstances.Network ()
3943import Ouroboros.Consensus.Ledger.SupportsMempool
@@ -174,6 +178,9 @@ data NodeConfiguration
174178 , ncGenesisConfig :: GenesisConfig
175179
176180 , ncResponderCoreAffinityPolicy :: ResponderCoreAffinityPolicy
181+
182+ -- gRPC
183+ , ncRpcConfig :: RpcConfig
177184 } deriving (Eq , Show )
178185
179186-- | We expose the `Ouroboros.Network.Mux.ForkPolicy` as a `NodeConfiguration` field.
@@ -255,6 +262,7 @@ data PartialNodeConfiguration
255262 , pncSyncTargetOfKnownBigLedgerPeers :: ! (Last Int )
256263 , pncSyncTargetOfEstablishedBigLedgerPeers :: ! (Last Int )
257264 , pncSyncTargetOfActiveBigLedgerPeers :: ! (Last Int )
265+
258266 -- Minimum number of active big ledger peers we must be connected to
259267 -- in Genesis mode
260268 , pncMinBigLedgerPeersForTrustedState :: ! (Last NumberOfBigLedgerPeers )
@@ -269,6 +277,9 @@ data PartialNodeConfiguration
269277 , pncGenesisConfigFlags :: ! (Last GenesisConfigFlags )
270278
271279 , pncResponderCoreAffinityPolicy :: ! (Last ResponderCoreAffinityPolicy )
280+
281+ -- gRPC
282+ , pncRpcConfig :: ! PartialRpcConfig
272283 } deriving (Eq , Generic , Show )
273284
274285instance AdjustFilePaths PartialNodeConfiguration where
@@ -381,6 +392,12 @@ instance FromJSON PartialNodeConfiguration where
381392 <$> v .:? " ResponderCoreAffinityPolicy"
382393 <*> v .:? " ForkPolicy" -- deprecated
383394
395+ pncRpcConfig <-
396+ RpcConfig
397+ <$> (Last <$> v .:? " EnableRpc" )
398+ <*> (Last <$> v .:? " RpcSocketPath" )
399+ <*> pure mempty
400+
384401 pure PartialNodeConfiguration {
385402 pncProtocolConfig
386403 , pncSocketConfig = Last . Just $ SocketConfig mempty mempty mempty pncSocketPath
@@ -425,6 +442,7 @@ instance FromJSON PartialNodeConfiguration where
425442 , pncPeerSharing
426443 , pncGenesisConfigFlags
427444 , pncResponderCoreAffinityPolicy
445+ , pncRpcConfig
428446 }
429447 where
430448 parseMempoolCapacityBytesOverride v = parseNoOverride <|> parseOverride
@@ -687,6 +705,7 @@ defaultPartialNodeConfiguration =
687705 , pncGenesisConfigFlags = Last (Just defaultGenesisConfigFlags)
688706 -- https://ouroboros-consensus.cardano.intersectmbo.org/haddocks/ouroboros-consensus-diffusion/Ouroboros-Consensus-Node-Genesis.html#v:defaultGenesisConfigFlags
689707 , pncResponderCoreAffinityPolicy = Last $ Just NoResponderCoreAffinity
708+ , pncRpcConfig = mempty
690709 }
691710
692711lastOption :: Parser a -> Parser (Last a )
@@ -827,6 +846,9 @@ makeNodeConfiguration pnc = do
827846 experimentalProtocols <-
828847 lastToEither " Missing ExperimentalProtocolsEnabled" $
829848 pncExperimentalProtocolsEnabled pnc
849+
850+ ncRpcConfig <- makeRpcConfig $ (pncRpcConfig pnc){nodeSocketPath= ncSocketPath socketConfig}
851+
830852 return $ NodeConfiguration
831853 { ncConfigFile = configFile
832854 , ncTopologyFile = topologyFile
@@ -872,6 +894,7 @@ makeNodeConfiguration pnc = do
872894 , ncConsensusMode
873895 , ncGenesisConfig
874896 , ncResponderCoreAffinityPolicy
897+ , ncRpcConfig
875898 }
876899
877900ncProtocol :: NodeConfiguration -> Protocol
0 commit comments