Skip to content

Commit

Permalink
consensus: don't require NetworkMagic in StdRunNodeArgs
Browse files Browse the repository at this point in the history
`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`.
  • Loading branch information
mrBliss committed Nov 12, 2020
1 parent fa567f3 commit df460d0
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions ouroboros-consensus/src/Ouroboros/Consensus/Node.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
--
Expand Down Expand Up @@ -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
}
Expand All @@ -620,15 +619,16 @@ 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
LocalAddress
NodeToNodeVersionData
NodeToClientVersionData
blk)
stdLowLevelRunNodeArgsIO StdRunNodeArgs{..} = do
stdLowLevelRunNodeArgsIO RunNodeArgs{ rnProtocolInfo } StdRunNodeArgs{..} = do
llrnBfcSalt <- stdBfcSaltIO
llrnKeepAliveRng <- stdKeepAliveRngIO
pure LowLevelRunNodeArgs
Expand All @@ -644,24 +644,27 @@ 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
}
where
mkHasFS :: ChainDB.RelativeMountPoint -> SomeHasFS IO
mkHasFS = stdMkChainDbHasFS srnDatabasePath

networkMagic :: NetworkMagic
networkMagic = getNetworkMagic $ configBlock $ pInfoConfig rnProtocolInfo

updateChainDbDefaults ::
ChainDbArgs Defaults IO blk
-> ChainDbArgs Defaults IO blk
Expand Down

0 comments on commit df460d0

Please sign in to comment.