@@ -42,6 +42,7 @@ module Ouroboros.Consensus.Node (
4242 , LastShutDownWasClean (.. )
4343 , LowLevelRunNodeArgs (.. )
4444 , MempoolCapacityBytesOverride (.. )
45+ , NodeDatabasePaths (.. )
4546 , NodeKernel (.. )
4647 , NodeKernelArgs (.. )
4748 , ProtocolInfo (.. )
@@ -221,9 +222,13 @@ data LowLevelRunNodeArgs m addrNTN addrNTC versionDataNTN versionDataNTC blk
221222 -- | The " static " ChainDB arguments
222223 , llrnChainDbArgsDefaults :: Incomplete ChainDbArgs m blk
223224
224- -- | File-system on which the directories for the different databases will
225+ -- | File-system on which the directory for the ImmutableDB will
225226 -- be created.
226- , llrnMkHasFS :: ChainDB. RelativeMountPoint -> SomeHasFS m
227+ , llrnMkImmutableHasFS :: ChainDB. RelativeMountPoint -> SomeHasFS m
228+
229+ -- | File-system on which the directories for databases other than the ImmutableDB will
230+ -- be created.
231+ , llrnMkVolatileHasFS :: ChainDB. RelativeMountPoint -> SomeHasFS m
227232
228233 -- | Customise the 'ChainDbArgs'
229234 , llrnCustomiseChainDbArgs ::
@@ -285,6 +290,27 @@ data LowLevelRunNodeArgs m addrNTN addrNTC versionDataNTN versionDataNTC blk
285290 , llrnPublicPeerSelectionStateVar :: StrictSTM. StrictTVar m (Diffusion. PublicPeerSelectionState addrNTN )
286291 }
287292
293+ data NodeDatabasePaths =
294+ OnePathForAllDbs
295+ FilePath -- ^ Databases will be stored under this path, such that given a
296+ -- path @/foo@, databases will be in @/foo/{immutable,volatile,...}@.
297+ | MultipleDbPaths
298+ FilePath -- ^ Immutable path, usually pointing to a non-necessarily
299+ -- performant volume. ImmutableDB will be stored under this path,
300+ -- so given @/foo@, the ImmutableDB will be in @/foo/immutable@.
301+ FilePath -- ^ Non-immutable (volatile data) path, usually pointing to a
302+ -- performant volume. Databases other than the ImmutableDB will
303+ -- be stored under this path, so given @/bar@, it will contain
304+ -- @/bar/{volatile,ledger,...}@.
305+
306+ immutableDbPath :: NodeDatabasePaths -> FilePath
307+ immutableDbPath (OnePathForAllDbs f) = f
308+ immutableDbPath (MultipleDbPaths imm _) = imm
309+
310+ nonImmutableDbPath :: NodeDatabasePaths -> FilePath
311+ nonImmutableDbPath (OnePathForAllDbs f) = f
312+ nonImmutableDbPath (MultipleDbPaths _ vol) = vol
313+
288314-- | Higher-level arguments that can determine the 'LowLevelRunNodeArgs' under
289315-- some usual assumptions for realistic use cases such as in @cardano-node@.
290316--
@@ -295,7 +321,7 @@ data StdRunNodeArgs m blk (p2p :: Diffusion.P2P) = StdRunNodeArgs
295321 , srnChainDbValidateOverride :: Bool
296322 -- ^ If @True@, validate the ChainDB on init no matter what
297323 , srnDiskPolicyArgs :: DiskPolicyArgs
298- , srnDatabasePath :: FilePath
324+ , srnDatabasePath :: NodeDatabasePaths
299325 -- ^ Location of the DBs
300326 , srnDiffusionArguments :: Diffusion. Arguments
301327 IO
@@ -431,7 +457,8 @@ runWith RunNodeArgs{..} encAddrNtN decAddrNtN LowLevelRunNodeArgs{..} =
431457 inFuture
432458 cfg
433459 initLedger
434- llrnMkHasFS
460+ llrnMkImmutableHasFS
461+ llrnMkVolatileHasFS
435462 llrnChainDbArgsDefaults
436463 ( setLoEinChainDbArgs
437464 . maybeValidateAll
@@ -686,20 +713,24 @@ openChainDB ::
686713 -> ExtLedgerState blk
687714 -- ^ Initial ledger
688715 -> (ChainDB. RelativeMountPoint -> SomeHasFS m )
716+ -- ^ Immutable FS, see 'NodeDatabasePaths'
717+ -> (ChainDB. RelativeMountPoint -> SomeHasFS m )
718+ -- ^ Volatile FS, see 'NodeDatabasePaths'
689719 -> Incomplete ChainDbArgs m blk
690720 -- ^ A set of default arguments (possibly modified from 'defaultArgs')
691721 -> (Complete ChainDbArgs m blk -> Complete ChainDbArgs m blk )
692722 -- ^ Customise the 'ChainDbArgs'
693723 -> m (ChainDB m blk , Complete ChainDbArgs m blk )
694- openChainDB registry inFuture cfg initLedger fs defArgs customiseArgs =
724+ openChainDB registry inFuture cfg initLedger fsImm fsVol defArgs customiseArgs =
695725 let args = customiseArgs $ ChainDB. completeChainDbArgs
696726 registry
697727 inFuture
698728 cfg
699729 initLedger
700730 (nodeImmutableDbChunkInfo (configStorage cfg))
701731 (nodeCheckIntegrity (configStorage cfg))
702- fs
732+ fsImm
733+ fsVol
703734 defArgs
704735 in (,args) <$> ChainDB. openDB args
705736
@@ -876,7 +907,8 @@ stdLowLevelRunNodeArgsIO RunNodeArgs{ rnProtocolInfo
876907 , llrnCustomiseHardForkBlockchainTimeArgs = id
877908 , llrnGsmAntiThunderingHerd
878909 , llrnKeepAliveRng
879- , llrnMkHasFS = stdMkChainDbHasFS srnDatabasePath
910+ , llrnMkImmutableHasFS = stdMkChainDbHasFS $ immutableDbPath srnDatabasePath
911+ , llrnMkVolatileHasFS = stdMkChainDbHasFS $ nonImmutableDbPath srnDatabasePath
880912 , llrnChainDbArgsDefaults = updateChainDbDefaults ChainDB. defaultArgs
881913 , llrnCustomiseChainDbArgs = id
882914 , llrnCustomiseNodeKernelArgs
@@ -910,7 +942,9 @@ stdLowLevelRunNodeArgsIO RunNodeArgs{ rnProtocolInfo
910942 snd
911943 (supportedNodeToClientVersions (Proxy @ blk ))
912944 , llrnWithCheckedDB =
913- stdWithCheckedDB (Proxy @ blk ) srnTraceChainDB srnDatabasePath networkMagic
945+ -- 'stdWithCheckedDB' uses the FS just to check for the clean file.
946+ -- We put that one in the immutable path.
947+ stdWithCheckedDB (Proxy @ blk ) srnTraceChainDB (immutableDbPath srnDatabasePath) networkMagic
914948 , llrnMaxCaughtUpAge = secondsToNominalDiffTime $ 20 * 60 -- 20 min
915949 , llrnMaxClockSkew =
916950 InFuture. defaultClockSkew
0 commit comments