From e8c011cd9f1c6c04d6a8ca27791fa9f5440b0bf4 Mon Sep 17 00:00:00 2001 From: Thomas Winant Date: Thu, 12 Nov 2020 12:17:22 +0100 Subject: [PATCH] consensus: don't require NetworkMagic in StdRunNodeArgs `RunNodeArgs` contains the `ProtocolInfo`, which already contains the `NetworkMagic`. So don't require it in `StdRunNodeArgs` but derive it from the `RunNodeArgs`. This means we have to pass `RunNodeArgs` to `stdLowLevelRunNodeArgsIO`. --- .../src/Ouroboros/Consensus/Node.hs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ouroboros-consensus/src/Ouroboros/Consensus/Node.hs b/ouroboros-consensus/src/Ouroboros/Consensus/Node.hs index c602a1578f0..c1cab1207dc 100644 --- a/ouroboros-consensus/src/Ouroboros/Consensus/Node.hs +++ b/ouroboros-consensus/src/Ouroboros/Consensus/Node.hs @@ -205,7 +205,7 @@ run :: forall blk. => RunNodeArgs IO RemoteAddress LocalAddress blk -> StdRunNodeArgs IO blk -> IO () -run args stdArgs = stdLowLevelRunNodeArgsIO stdArgs >>= runWith args +run args stdArgs = stdLowLevelRunNodeArgsIO args stdArgs >>= runWith args -- | Start a node. -- @@ -611,7 +611,6 @@ data StdRunNodeArgs m blk = StdRunNodeArgs -- ^ Location of the DBs , srnDiffusionArguments :: DiffusionArguments , srnDiffusionTracers :: DiffusionTracers - , srnNetworkMagic :: NetworkMagic , srnTraceChainDB :: Tracer m (ChainDB.TraceEvent blk) -- ^ ChainDB Tracer } @@ -620,7 +619,8 @@ data StdRunNodeArgs m blk = StdRunNodeArgs -- non-testing invocation. stdLowLevelRunNodeArgsIO :: forall blk. RunNode blk - => StdRunNodeArgs IO blk + => RunNodeArgs IO RemoteAddress LocalAddress blk + -> StdRunNodeArgs IO blk -> IO (LowLevelRunNodeArgs IO RemoteAddress @@ -628,7 +628,7 @@ stdLowLevelRunNodeArgsIO :: NodeToNodeVersionData NodeToClientVersionData blk) -stdLowLevelRunNodeArgsIO StdRunNodeArgs{..} = do +stdLowLevelRunNodeArgsIO RunNodeArgs{ rnProtocolInfo } StdRunNodeArgs{..} = do llrnBfcSalt <- stdBfcSaltIO llrnKeepAliveRng <- stdKeepAliveRngIO pure LowLevelRunNodeArgs @@ -644,17 +644,17 @@ stdLowLevelRunNodeArgsIO StdRunNodeArgs{..} = do \_reg apps -> stdRunDataDiffusion srnDiffusionTracers srnDiffusionArguments apps , llrnVersionDataNTC = - stdVersionDataNTC srnNetworkMagic + stdVersionDataNTC networkMagic , llrnVersionDataNTN = stdVersionDataNTN - srnNetworkMagic + networkMagic (daDiffusionMode srnDiffusionArguments) , llrnNodeToNodeVersions = supportedNodeToNodeVersions (Proxy @blk) , llrnNodeToClientVersions = supportedNodeToClientVersions (Proxy @blk) , llrnWithCheckedDB = - stdWithCheckedDB srnDatabasePath srnNetworkMagic + stdWithCheckedDB srnDatabasePath networkMagic , llrnMaxClockSkew = InFuture.defaultClockSkew } @@ -662,6 +662,9 @@ stdLowLevelRunNodeArgsIO StdRunNodeArgs{..} = do mkHasFS :: ChainDB.RelativeMountPoint -> SomeHasFS IO mkHasFS = stdMkChainDbHasFS srnDatabasePath + networkMagic :: NetworkMagic + networkMagic = getNetworkMagic $ configBlock $ pInfoConfig rnProtocolInfo + updateChainDbDefaults :: ChainDbArgs Defaults IO blk -> ChainDbArgs Defaults IO blk