hydra-node
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.Node

Description

Top-level module to run a single Hydra node.

Checkout Hydra Documentation for some details about the overall architecture of the Node.

Synopsis

Environment Handling

initEnvironment :: RunOptions -> IO Environment Source #

Initialize 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.

hydrate :: (IsChainState tx, MonadDelay m, MonadLabelledSTM m, MonadAsync m, MonadThrow m, MonadUnliftIO m) => Tracer m (HydraNodeLog tx) -> Environment -> Ledger tx -> ChainStateType tx -> EventStore (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.

mkNetworkInput :: Party -> Message tx -> Input tx Source #

Create a network input with corresponding default ttl from given sender.

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.

data HydraNode tx m Source #

Fully connected hydra node with everything wired in.

runHydraNode :: (MonadCatch m, MonadAsync m, MonadTime m, IsChainState tx) => HydraNode tx m -> m () Source #

stepHydraNode :: (MonadCatch m, MonadAsync m, MonadTime m, IsChainState tx) => UTCTime -> HydraNode tx m -> m () Source #

defaultTTL :: TTL Source #

The maximum number of times to re-enqueue a network messages upon Wait. outcome.

defaultTxTTL :: TTL Source #

The maximum number of times to re-enqueue ReqTx and ReqDec network messages upon Wait.

waitDelay :: DiffTime Source #

The time to wait between re-enqueuing a Wait outcome.

processNextInput :: IsChainState tx => HydraNode tx m -> Input tx -> UTCTime -> STM m (Outcome tx) Source #

Monadic interface around update.

processStateChanges :: (MonadSTM m, MonadTime 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

data NodeStateHandler tx m Source #

Handle to access and modify the state in the Hydra Node.

Constructors

NodeStateHandler 

Fields

createNodeStateHandler Source #

Arguments

:: MonadLabelledSTM m 
=> Maybe EventId

Last seen EventId.

-> NodeState tx 
-> m (NodeStateHandler tx m) 

Initialize a new NodeStateHandler.

Logging

data HydraNodeLog tx Source #

Constructors

BeginInput 

Fields

EndInput 

Fields

BeginEffect 

Fields

EndEffect 

Fields

LogicOutcome 

Fields

DroppedFromQueue 

Fields

LoadingState 
LoadedState 
LoadedChainState 

Fields

ReplayingState 
Misconfiguration 

Instances

Instances details
IsChainState tx => ToJSON (HydraNodeLog tx) Source # 
Instance details

Defined in Hydra.Node

Methods

toJSON :: HydraNodeLog tx -> Value

toEncoding :: HydraNodeLog tx -> Encoding

toJSONList :: [HydraNodeLog tx] -> Value

toEncodingList :: [HydraNodeLog tx] -> Encoding

omitField :: HydraNodeLog tx -> Bool

Generic (HydraNodeLog tx) Source # 
Instance details

Defined in Hydra.Node

Associated Types

type Rep (HydraNodeLog tx) :: Type -> Type Source #

IsChainState tx => Show (HydraNodeLog tx) Source # 
Instance details

Defined in Hydra.Node

IsChainState tx => Eq (HydraNodeLog tx) Source # 
Instance details

Defined in Hydra.Node

type Rep (HydraNodeLog tx) Source # 
Instance details

Defined in Hydra.Node

type Rep (HydraNodeLog tx) = D1 ('MetaData "HydraNodeLog" "Hydra.Node" "hydra-node-2.3.0-1cgalYNmLJQC1YXlYVq7mp" 'False) (((C1 ('MetaCons "BeginInput" 'PrefixI 'True) (S1 ('MetaSel ('Just "by") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Party) :*: (S1 ('MetaSel ('Just "inputId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Just "input") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Input tx)))) :+: C1 ('MetaCons "EndInput" 'PrefixI 'True) (S1 ('MetaSel ('Just "by") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Party) :*: S1 ('MetaSel ('Just "inputId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Word64))) :+: (C1 ('MetaCons "BeginEffect" 'PrefixI 'True) ((S1 ('MetaSel ('Just "by") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Party) :*: S1 ('MetaSel ('Just "inputId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Word64)) :*: (S1 ('MetaSel ('Just "effectId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Word32) :*: S1 ('MetaSel ('Just "effect") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Effect tx)))) :+: (C1 ('MetaCons "EndEffect" 'PrefixI 'True) (S1 ('MetaSel ('Just "by") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Party) :*: (S1 ('MetaSel ('Just "inputId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Just "effectId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Word32))) :+: C1 ('MetaCons "LogicOutcome" 'PrefixI 'True) (S1 ('MetaSel ('Just "by") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Party) :*: S1 ('MetaSel ('Just "outcome") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Outcome tx)))))) :+: ((C1 ('MetaCons "DroppedFromQueue" 'PrefixI 'True) (S1 ('MetaSel ('Just "inputId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Just "input") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Input tx))) :+: (C1 ('MetaCons "LoadingState" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LoadedState" 'PrefixI 'True) (S1 ('MetaSel ('Just "lastEventId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Last EventId)) :*: S1 ('MetaSel ('Just "nodeState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (NodeState tx))))) :+: (C1 ('MetaCons "LoadedChainState" 'PrefixI 'True) (S1 ('MetaSel ('Just "lastKnownChainPoint") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (ChainPointType tx))) :+: (C1 ('MetaCons "ReplayingState" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Misconfiguration" 'PrefixI 'True) (S1 ('MetaSel ('Just "misconfigurationErrors") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [ParamMismatch]))))))