Skip to content

Commit

Permalink
Draft extension points in Hydra.Node.Run
Browse files Browse the repository at this point in the history
Current idea: Keep notes where extensions are possible so we don't
change things by accident breaking external/custom code of users.
  • Loading branch information
ch1bo committed Mar 4, 2024
1 parent b49a47a commit 95ea20a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions hydra-node/src/Hydra/Events.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
-- 'EventSource' and 'EventSink' instances and is intended to be used as an
-- extension point. A single 'EventSource' and zero or more 'EventSink' handles
-- are used by the main 'HydraNode' handle to load and send out events.
--
-- TODO: add an example event source sink (on top of the persistence one)
module Hydra.Events where

import Hydra.Prelude
Expand Down
20 changes: 10 additions & 10 deletions hydra-node/src/Hydra/Node/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,20 @@ run opts = do
eq@EventQueue{putEvent} <- createEventQueue
let RunOptions{chainConfig, ledgerConfig} = opts
pparams <- readJsonFileThrow pparamsFromJson (cardanoLedgerProtocolParametersFile ledgerConfig)

globals <- getGlobalsForChain chainConfig

withCardanoLedger pparams globals $ \ledger -> do
-- Setup event source and sinks
persistence <- createPersistenceIncremental $ persistenceDir <> "/state"
-- TODO(Elaine): remove in favor of eventSource/Sink directly
-- (eventSource, eventSink) <- createEventPairIncremental $ persistenceDir <> "/state"

let (eventSource, eventSink) = eventPairFromPersistenceIncremental persistence
eventSinks = [eventSink] -- FIXME(Elaine): load other event sinks
-- eventSinksSansSource = [] --TODO(Elaine): this needs a better name. essentially, don't load events back into where they came from, at least until disk-based persistence can handle redelivery
-- persistence@(eventSource, eventSinks) <- createNewPersistenceIncremental $ persistenceDir <> "/state"
let (eventSource, filePersistenceSink) = eventPairFromPersistenceIncremental persistence
-- NOTE: Add any custom sink setup code here
-- customSink <- createCustomSink
let eventSinks =
[ filePersistenceSink
-- NOTE: Add any custom sinks here
-- , customSink
]
-- Load events and hydrate sinks
(hs, chainStateHistory) <- loadStateEventSource (contramap Node tracer) eventSource eventSinks initialChainState

checkHeadState (contramap Node tracer) env hs
nodeState <- createNodeState hs
-- Chain
Expand Down

0 comments on commit 95ea20a

Please sign in to comment.