hydra-node-0.19.0: The 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 #

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.

Instances

Instances details
HasParty (DraftHydraNode tx m) Source # 
Instance details

Defined in Hydra.Node

Methods

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.

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.

Constructors

HydraNode 

Fields

Instances

Instances details
HasParty (HydraNode tx m) Source # 
Instance details

Defined in Hydra.Node

Methods

getParty :: HydraNode tx m -> Party

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

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

waitDelay :: DiffTime Source #

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

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

data NodeState tx m Source #

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

Constructors

NodeState 

Fields

createNodeState Source #

Arguments

:: MonadLabelledSTM m 
=> Maybe EventId

Last seen EventId.

-> HeadState tx 
-> m (NodeState tx m) 

Initialize a new NodeState.

Logging

data HydraNodeLog tx Source #

Constructors

BeginInput 

Fields

EndInput 

Fields

BeginEffect 

Fields

EndEffect 

Fields

LogicOutcome 

Fields

DroppedFromQueue 

Fields

LoadedState 
Misconfiguration 

Instances

Instances details
(ArbitraryIsTx tx, IsChainState tx) => Arbitrary (HydraNodeLog tx) Source # 
Instance details

Defined in Hydra.Node

Methods

arbitrary :: Gen (HydraNodeLog tx)

shrink :: HydraNodeLog tx -> [HydraNodeLog tx]

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

Defined in Hydra.Node

Methods

parseJSON :: Value -> Parser (HydraNodeLog tx)

parseJSONList :: Value -> Parser [HydraNodeLog tx]

omittedField :: Maybe (HydraNodeLog tx)

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-0.19.0-6Z4E5vp1s1XJuLOmmEVMTw" 'False) (((C1 ('MetaCons "BeginInput" 'PrefixI 'True) (S1 ('MetaSel ('Just "by") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Party) :*: (S1 ('MetaSel ('Just "inputId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64) :*: S1 ('MetaSel ('Just "input") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Input tx)))) :+: C1 ('MetaCons "EndInput" 'PrefixI 'True) (S1 ('MetaSel ('Just "by") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Party) :*: S1 ('MetaSel ('Just "inputId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64))) :+: (C1 ('MetaCons "BeginEffect" 'PrefixI 'True) ((S1 ('MetaSel ('Just "by") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Party) :*: S1 ('MetaSel ('Just "inputId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64)) :*: (S1 ('MetaSel ('Just "effectId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word32) :*: S1 ('MetaSel ('Just "effect") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Effect tx)))) :+: C1 ('MetaCons "EndEffect" 'PrefixI 'True) (S1 ('MetaSel ('Just "by") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Party) :*: (S1 ('MetaSel ('Just "inputId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64) :*: S1 ('MetaSel ('Just "effectId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word32))))) :+: ((C1 ('MetaCons "LogicOutcome" 'PrefixI 'True) (S1 ('MetaSel ('Just "by") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Party) :*: S1 ('MetaSel ('Just "outcome") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Outcome tx))) :+: C1 ('MetaCons "DroppedFromQueue" 'PrefixI 'True) (S1 ('MetaSel ('Just "inputId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64) :*: S1 ('MetaSel ('Just "input") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Input tx)))) :+: (C1 ('MetaCons "LoadedState" 'PrefixI 'True) (S1 ('MetaSel ('Just "numberOfEvents") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64)) :+: C1 ('MetaCons "Misconfiguration" 'PrefixI 'True) (S1 ('MetaSel ('Just "misconfigurationErrors") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [ParamMismatch])))))