Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Top-level module to run a single Hydra node.
Checkout Hydra
Documentation
for some details about the overall architecture of the Node
.
Synopsis
- initEnvironment :: RunOptions -> IO Environment
- checkHeadState :: MonadThrow m => Tracer m (HydraNodeLog tx) -> Environment -> HeadState tx -> m ()
- data DraftHydraNode tx m = DraftHydraNode {
- tracer :: Tracer m (HydraNodeLog tx)
- env :: Environment
- ledger :: Ledger tx
- nodeState :: NodeState tx m
- inputQueue :: InputQueue m (Input tx)
- eventSource :: EventSource (StateEvent tx) m
- eventSinks :: [EventSink (StateEvent tx) m]
- chainStateHistory :: ChainStateHistory tx
- hydrate :: (MonadDelay m, MonadLabelledSTM m, MonadAsync m, MonadThrow m, IsChainState tx) => Tracer m (HydraNodeLog tx) -> Environment -> Ledger tx -> ChainStateType tx -> EventSource (StateEvent tx) m -> [EventSink (StateEvent tx) m] -> m (DraftHydraNode tx m)
- wireChainInput :: DraftHydraNode tx m -> ChainEvent tx -> m ()
- wireClientInput :: DraftHydraNode tx m -> ClientInput tx -> m ()
- wireNetworkInput :: DraftHydraNode tx m -> NetworkCallback (NetworkEvent (Message tx)) m
- connect :: Monad m => Chain tx m -> Network m (Message tx) -> Server tx m -> DraftHydraNode tx m -> m (HydraNode tx m)
- data HydraNode tx m = HydraNode {
- tracer :: Tracer m (HydraNodeLog tx)
- env :: Environment
- ledger :: Ledger tx
- nodeState :: NodeState tx m
- inputQueue :: InputQueue m (Input tx)
- eventSource :: EventSource (StateEvent tx) m
- eventSinks :: [EventSink (StateEvent tx) m]
- oc :: Chain tx m
- hn :: Network m (Message tx)
- server :: Server tx m
- runHydraNode :: (MonadCatch m, MonadAsync m, IsChainState tx) => HydraNode tx m -> m ()
- stepHydraNode :: (MonadCatch m, MonadAsync m, IsChainState tx) => HydraNode tx m -> m ()
- waitDelay :: DiffTime
- processNextInput :: IsChainState tx => HydraNode tx m -> Input tx -> STM m (Outcome tx)
- processStateChanges :: MonadSTM m => HydraNode tx m -> [StateChanged tx] -> m ()
- processEffects :: (MonadAsync m, MonadCatch m, IsChainState tx) => HydraNode tx m -> Tracer m (HydraNodeLog tx) -> Word64 -> [Effect tx] -> m ()
- data NodeState tx m = NodeState {
- modifyHeadState :: forall a. (HeadState tx -> (a, HeadState tx)) -> STM m a
- queryHeadState :: STM m (HeadState tx)
- getNextEventId :: STM m EventId
- createNodeState :: MonadLabelledSTM m => Maybe EventId -> HeadState tx -> m (NodeState tx m)
- data HydraNodeLog tx
- = BeginInput { }
- | EndInput { }
- | BeginEffect { }
- | EndEffect { }
- | LogicOutcome { }
- | DroppedFromQueue { }
- | LoadedState { }
- | Misconfiguration { }
Environment Handling
initEnvironment :: RunOptions -> IO Environment Source #
Intialize the Environment
from command line options.
checkHeadState :: MonadThrow m => Tracer m (HydraNodeLog tx) -> Environment -> HeadState tx -> m () Source #
Checks that command line options match a given HeadState
. This function
takes Environment
because it is derived from RunOptions
via
initEnvironment
.
Throws: ParameterMismatch
when state not matching the environment.
Create and run a hydra node
data DraftHydraNode tx m Source #
A draft version of the HydraNode
that holds state, but is not yet
connected (see connect
). This is commonly created by the hydrate
smart
constructor.
DraftHydraNode | |
|
Instances
HasParty (DraftHydraNode tx m) Source # | |
Defined in Hydra.Node getParty :: DraftHydraNode tx m -> Party |
hydrate :: (MonadDelay m, MonadLabelledSTM m, MonadAsync m, MonadThrow m, IsChainState tx) => Tracer m (HydraNodeLog tx) -> Environment -> Ledger tx -> ChainStateType tx -> EventSource (StateEvent tx) m -> [EventSink (StateEvent tx) m] -> m (DraftHydraNode tx m) Source #
Hydrate a DraftHydraNode
by loading events from source, re-aggregate node
state and sending events to sinks while doing so.
wireChainInput :: DraftHydraNode tx m -> ChainEvent tx -> m () Source #
wireClientInput :: DraftHydraNode tx m -> ClientInput tx -> m () Source #
wireNetworkInput :: DraftHydraNode tx m -> NetworkCallback (NetworkEvent (Message tx)) m Source #
connect :: Monad m => Chain tx m -> Network m (Message tx) -> Server tx m -> DraftHydraNode tx m -> m (HydraNode tx m) Source #
Connect chain, network and API to a hydrated DraftHydraNode
to get a fully
connected HydraNode
.
Fully connected hydra node with everything wired in.
HydraNode | |
|
runHydraNode :: (MonadCatch m, MonadAsync m, IsChainState tx) => HydraNode tx m -> m () Source #
stepHydraNode :: (MonadCatch m, MonadAsync m, IsChainState tx) => HydraNode tx m -> m () Source #
processNextInput :: IsChainState tx => HydraNode tx m -> Input tx -> STM m (Outcome tx) Source #
Monadic interface around update
.
processStateChanges :: MonadSTM m => HydraNode tx m -> [StateChanged tx] -> m () Source #
processEffects :: (MonadAsync m, MonadCatch m, IsChainState tx) => HydraNode tx m -> Tracer m (HydraNodeLog tx) -> Word64 -> [Effect tx] -> m () Source #
Manage state
Handle to access and modify the state in the Hydra Node.
NodeState | |
|
Initialize a new NodeState
.
Logging
data HydraNodeLog tx Source #
BeginInput | |
EndInput | |
BeginEffect | |
EndEffect | |
LogicOutcome | |
DroppedFromQueue | |
LoadedState | |
Misconfiguration | |