hydra-node-0.13.0: The Hydra node
Safe HaskellSafe-Inferred
LanguageHaskell2010

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.

data ParamMismatch Source #

Instances

Instances details
Arbitrary ParamMismatch Source # 
Instance details

Defined in Hydra.Node

FromJSON ParamMismatch Source # 
Instance details

Defined in Hydra.Node

Methods

parseJSON :: Value -> Parser ParamMismatch

parseJSONList :: Value -> Parser [ParamMismatch]

ToJSON ParamMismatch Source # 
Instance details

Defined in Hydra.Node

Methods

toJSON :: ParamMismatch -> Value

toEncoding :: ParamMismatch -> Encoding

toJSONList :: [ParamMismatch] -> Value

toEncodingList :: [ParamMismatch] -> Encoding

Generic ParamMismatch Source # 
Instance details

Defined in Hydra.Node

Associated Types

type Rep ParamMismatch :: Type -> Type Source #

Show ParamMismatch Source # 
Instance details

Defined in Hydra.Node

Eq ParamMismatch Source # 
Instance details

Defined in Hydra.Node

type Rep ParamMismatch Source # 
Instance details

Defined in Hydra.Node

type Rep ParamMismatch = D1 ('MetaData "ParamMismatch" "Hydra.Node" "hydra-node-0.13.0-HKlbaPrFKjs2dhEMwn7ono" 'False) (C1 ('MetaCons "ContestationPeriodMismatch" 'PrefixI 'True) (S1 ('MetaSel ('Just "loadedCp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ContestationPeriod) :*: S1 ('MetaSel ('Just "configuredCp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ContestationPeriod)) :+: C1 ('MetaCons "PartiesMismatch" 'PrefixI 'True) (S1 ('MetaSel ('Just "loadedParties") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Party]) :*: S1 ('MetaSel ('Just "configuredParties") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Party])))

checkHeadState :: MonadThrow m => Tracer m (HydraNodeLog tx) -> Environment -> HeadState tx -> m () Source #

Checks that command line options match a given HeadState. This funciton 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 HydraNode tx m Source #

Main handle of a hydra node where all layers are tied together.

Constructors

HydraNode 

Fields

data HydraNodeLog tx Source #

Instances

Instances details
(IsTx tx, Arbitrary (ChainStateType 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]

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

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.13.0-HKlbaPrFKjs2dhEMwn7ono" 'False) ((C1 ('MetaCons "BeginEvent" 'PrefixI 'True) (S1 ('MetaSel ('Just "by") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Party) :*: (S1 ('MetaSel ('Just "eventId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64) :*: S1 ('MetaSel ('Just "event") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Event tx)))) :+: (C1 ('MetaCons "EndEvent" 'PrefixI 'True) (S1 ('MetaSel ('Just "by") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Party) :*: S1 ('MetaSel ('Just "eventId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64)) :+: C1 ('MetaCons "BeginEffect" 'PrefixI 'True) ((S1 ('MetaSel ('Just "by") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Party) :*: S1 ('MetaSel ('Just "eventId") '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 "eventId") '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 "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])))))

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

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

waitDelay :: DiffTime Source #

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

processNextEvent :: IsChainState tx => HydraNode tx m -> Event tx -> STM m (Outcome tx) Source #

Monadic interface around update.

processEffects :: (MonadAsync m, MonadCatch m, IsChainState tx) => HydraNode tx m -> Tracer m (HydraNodeLog tx) -> Word64 -> Outcome 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 :: MonadLabelledSTM m => HeadState tx -> m (NodeState tx m) Source #

Initialize a new NodeState.

loadState :: (MonadThrow m, IsChainState tx) => Tracer m (HydraNodeLog tx) -> PersistenceIncremental (StateChanged tx) m -> ChainStateType tx -> m (HeadState tx) Source #

Load a HeadState from persistence.