hydra-node-0.16.0: The Hydra node
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.HeadLogic.State

Synopsis

Documentation

data HeadState tx Source #

The main state of the Hydra protocol state machine. It holds both, the overall protocol state, but also the off-chain CoordinatedHeadState.

Each of the sub-types (InitialState, OpenState, etc.) contain a black-box IdleState corresponding to the ChainEvent that has been observed leading to the state.

Note that rollbacks are currently not fully handled in the head logic and only this internal chain state gets replaced with the "rolled back to" version.

TODO: chainState would actualy not be needed in the HeadState anymore as we do not persist the HeadState and not access it in the HeadLogic either.

Constructors

Idle (IdleState tx) 
Initial (InitialState tx) 
Open (OpenState tx) 
Closed (ClosedState tx) 

Instances

Instances details
(IsTx tx, Arbitrary (ChainStateType tx)) => Arbitrary (HeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

arbitrary :: Gen (HeadState tx)

shrink :: HeadState tx -> [HeadState tx]

(IsTx tx, FromJSON (ChainStateType tx)) => FromJSON (HeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

parseJSON :: Value -> Parser (HeadState tx)

parseJSONList :: Value -> Parser [HeadState tx]

omittedField :: Maybe (HeadState tx)

(IsTx tx, ToJSON (ChainStateType tx)) => ToJSON (HeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

toJSON :: HeadState tx -> Value

toEncoding :: HeadState tx -> Encoding

toJSONList :: [HeadState tx] -> Value

toEncodingList :: [HeadState tx] -> Encoding

omitField :: HeadState tx -> Bool

Generic (HeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Associated Types

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

Methods

from :: HeadState tx -> Rep (HeadState tx) x Source #

to :: Rep (HeadState tx) x -> HeadState tx Source #

(IsTx tx, Show (ChainStateType tx)) => Show (HeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

(IsTx tx, Eq (ChainStateType tx)) => Eq (HeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

(==) :: HeadState tx -> HeadState tx -> Bool Source #

(/=) :: HeadState tx -> HeadState tx -> Bool Source #

type Rep (HeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

setChainState :: ChainStateType tx -> HeadState tx -> HeadState tx Source #

Update the chain state in any HeadState.

getHeadParameters :: HeadState tx -> Maybe HeadParameters Source #

Get the head parameters in any HeadState.

Idle

newtype IdleState tx Source #

An Idle head only having a chain state with things seen on chain so far.

Constructors

IdleState 

Instances

Instances details
Arbitrary (ChainStateType tx) => Arbitrary (IdleState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

arbitrary :: Gen (IdleState tx)

shrink :: IdleState tx -> [IdleState tx]

FromJSON (ChainStateType tx) => FromJSON (IdleState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

parseJSON :: Value -> Parser (IdleState tx)

parseJSONList :: Value -> Parser [IdleState tx]

omittedField :: Maybe (IdleState tx)

ToJSON (ChainStateType tx) => ToJSON (IdleState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

toJSON :: IdleState tx -> Value

toEncoding :: IdleState tx -> Encoding

toJSONList :: [IdleState tx] -> Value

toEncodingList :: [IdleState tx] -> Encoding

omitField :: IdleState tx -> Bool

Generic (IdleState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Associated Types

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

Methods

from :: IdleState tx -> Rep (IdleState tx) x Source #

to :: Rep (IdleState tx) x -> IdleState tx Source #

Show (ChainStateType tx) => Show (IdleState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Eq (ChainStateType tx) => Eq (IdleState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

(==) :: IdleState tx -> IdleState tx -> Bool Source #

(/=) :: IdleState tx -> IdleState tx -> Bool Source #

type Rep (IdleState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

type Rep (IdleState tx) = D1 ('MetaData "IdleState" "Hydra.HeadLogic.State" "hydra-node-0.16.0-C0XGScKIquG5I6dPp21445" 'True) (C1 ('MetaCons "IdleState" 'PrefixI 'True) (S1 ('MetaSel ('Just "chainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainStateType tx))))

Initial

data InitialState tx Source #

An Initial head which already has an identity and is collecting commits.

Instances

Instances details
(IsTx tx, Arbitrary (ChainStateType tx)) => Arbitrary (InitialState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

arbitrary :: Gen (InitialState tx)

shrink :: InitialState tx -> [InitialState tx]

(IsTx tx, FromJSON (ChainStateType tx)) => FromJSON (InitialState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

parseJSON :: Value -> Parser (InitialState tx)

parseJSONList :: Value -> Parser [InitialState tx]

omittedField :: Maybe (InitialState tx)

(IsTx tx, ToJSON (ChainStateType tx)) => ToJSON (InitialState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

toJSON :: InitialState tx -> Value

toEncoding :: InitialState tx -> Encoding

toJSONList :: [InitialState tx] -> Value

toEncodingList :: [InitialState tx] -> Encoding

omitField :: InitialState tx -> Bool

Generic (InitialState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Associated Types

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

(IsTx tx, Show (ChainStateType tx)) => Show (InitialState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

(IsTx tx, Eq (ChainStateType tx)) => Eq (InitialState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

type Rep (InitialState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Open

data OpenState tx Source #

An Open head with a CoordinatedHeadState tracking off-chain transactions.

Instances

Instances details
(IsTx tx, Arbitrary (ChainStateType tx)) => Arbitrary (OpenState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

arbitrary :: Gen (OpenState tx)

shrink :: OpenState tx -> [OpenState tx]

(IsTx tx, FromJSON (ChainStateType tx)) => FromJSON (OpenState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

parseJSON :: Value -> Parser (OpenState tx)

parseJSONList :: Value -> Parser [OpenState tx]

omittedField :: Maybe (OpenState tx)

(IsTx tx, ToJSON (ChainStateType tx)) => ToJSON (OpenState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

toJSON :: OpenState tx -> Value

toEncoding :: OpenState tx -> Encoding

toJSONList :: [OpenState tx] -> Value

toEncodingList :: [OpenState tx] -> Encoding

omitField :: OpenState tx -> Bool

Generic (OpenState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Associated Types

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

Methods

from :: OpenState tx -> Rep (OpenState tx) x Source #

to :: Rep (OpenState tx) x -> OpenState tx Source #

(IsTx tx, Show (ChainStateType tx)) => Show (OpenState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

(IsTx tx, Eq (ChainStateType tx)) => Eq (OpenState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

(==) :: OpenState tx -> OpenState tx -> Bool Source #

(/=) :: OpenState tx -> OpenState tx -> Bool Source #

type Rep (OpenState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

data CoordinatedHeadState tx Source #

Off-chain state of the Coordinated Head protocol.

Constructors

CoordinatedHeadState 

Fields

Instances

Instances details
IsTx tx => Arbitrary (CoordinatedHeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

IsTx tx => FromJSON (CoordinatedHeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

parseJSON :: Value -> Parser (CoordinatedHeadState tx)

parseJSONList :: Value -> Parser [CoordinatedHeadState tx]

omittedField :: Maybe (CoordinatedHeadState tx)

IsTx tx => ToJSON (CoordinatedHeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Generic (CoordinatedHeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Associated Types

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

IsTx tx => Show (CoordinatedHeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

IsTx tx => Eq (CoordinatedHeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

type Rep (CoordinatedHeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

type Rep (CoordinatedHeadState tx) = D1 ('MetaData "CoordinatedHeadState" "Hydra.HeadLogic.State" "hydra-node-0.16.0-C0XGScKIquG5I6dPp21445" 'False) (C1 ('MetaCons "CoordinatedHeadState" 'PrefixI 'True) ((S1 ('MetaSel ('Just "localUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx)) :*: S1 ('MetaSel ('Just "localTxs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [tx])) :*: (S1 ('MetaSel ('Just "allTxs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map (TxIdType tx) tx)) :*: (S1 ('MetaSel ('Just "confirmedSnapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ConfirmedSnapshot tx)) :*: S1 ('MetaSel ('Just "seenSnapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SeenSnapshot tx))))))

data SeenSnapshot tx Source #

Data structure to help in tracking whether we have seen or requested a ReqSn already and if seen, the signatures we collected already.

Constructors

NoSeenSnapshot

Never saw a ReqSn.

LastSeenSnapshot

No snapshot in flight with last seen snapshot number as given.

RequestedSnapshot

ReqSn was sent out and it should be considered already in flight.

SeenSnapshot

ReqSn for given snapshot was received.

Fields

Instances

Instances details
IsTx tx => Arbitrary (SeenSnapshot tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

arbitrary :: Gen (SeenSnapshot tx)

shrink :: SeenSnapshot tx -> [SeenSnapshot tx]

IsTx tx => FromJSON (SeenSnapshot tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

parseJSON :: Value -> Parser (SeenSnapshot tx)

parseJSONList :: Value -> Parser [SeenSnapshot tx]

omittedField :: Maybe (SeenSnapshot tx)

IsTx tx => ToJSON (SeenSnapshot tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

toJSON :: SeenSnapshot tx -> Value

toEncoding :: SeenSnapshot tx -> Encoding

toJSONList :: [SeenSnapshot tx] -> Value

toEncodingList :: [SeenSnapshot tx] -> Encoding

omitField :: SeenSnapshot tx -> Bool

Generic (SeenSnapshot tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Associated Types

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

IsTx tx => Show (SeenSnapshot tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

IsTx tx => Eq (SeenSnapshot tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

type Rep (SeenSnapshot tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

type Rep (SeenSnapshot tx) = D1 ('MetaData "SeenSnapshot" "Hydra.HeadLogic.State" "hydra-node-0.16.0-C0XGScKIquG5I6dPp21445" 'False) ((C1 ('MetaCons "NoSeenSnapshot" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LastSeenSnapshot" 'PrefixI 'True) (S1 ('MetaSel ('Just "lastSeen") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotNumber))) :+: (C1 ('MetaCons "RequestedSnapshot" 'PrefixI 'True) (S1 ('MetaSel ('Just "lastSeen") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotNumber) :*: S1 ('MetaSel ('Just "requested") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotNumber)) :+: C1 ('MetaCons "SeenSnapshot" 'PrefixI 'True) (S1 ('MetaSel ('Just "snapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Snapshot tx)) :*: S1 ('MetaSel ('Just "signatories") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map Party (Signature (Snapshot tx)))))))

seenSnapshotNumber :: SeenSnapshot tx -> SnapshotNumber Source #

Get the last seen snapshot number given a SeenSnapshot.

Closed

data ClosedState tx Source #

An Closed head with an current candidate ConfirmedSnapshot, which may be contested before the $sel:contestationDeadline:ClosedState.

Constructors

ClosedState 

Fields

Instances

Instances details
(IsTx tx, Arbitrary (ChainStateType tx)) => Arbitrary (ClosedState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

arbitrary :: Gen (ClosedState tx)

shrink :: ClosedState tx -> [ClosedState tx]

(IsTx tx, FromJSON (ChainStateType tx)) => FromJSON (ClosedState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

parseJSON :: Value -> Parser (ClosedState tx)

parseJSONList :: Value -> Parser [ClosedState tx]

omittedField :: Maybe (ClosedState tx)

(IsTx tx, ToJSON (ChainStateType tx)) => ToJSON (ClosedState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

toJSON :: ClosedState tx -> Value

toEncoding :: ClosedState tx -> Encoding

toJSONList :: [ClosedState tx] -> Value

toEncodingList :: [ClosedState tx] -> Encoding

omitField :: ClosedState tx -> Bool

Generic (ClosedState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Associated Types

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

Methods

from :: ClosedState tx -> Rep (ClosedState tx) x Source #

to :: Rep (ClosedState tx) x -> ClosedState tx Source #

(IsTx tx, Show (ChainStateType tx)) => Show (ClosedState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

(IsTx tx, Eq (ChainStateType tx)) => Eq (ClosedState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

type Rep (ClosedState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State