Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- data HeadState tx
- = Idle (IdleState tx)
- | Initial (InitialState tx)
- | Open (OpenState tx)
- | Closed (ClosedState tx)
- setChainState :: ChainStateType tx -> HeadState tx -> HeadState tx
- getHeadParameters :: HeadState tx -> Maybe HeadParameters
- newtype IdleState tx = IdleState {
- chainState :: ChainStateType tx
- data InitialState tx = InitialState {
- parameters :: HeadParameters
- pendingCommits :: PendingCommits
- committed :: Committed tx
- chainState :: ChainStateType tx
- headId :: HeadId
- headSeed :: HeadSeed
- type PendingCommits = Set Party
- type Committed tx = Map Party (UTxOType tx)
- data OpenState tx = OpenState {
- parameters :: HeadParameters
- coordinatedHeadState :: CoordinatedHeadState tx
- chainState :: ChainStateType tx
- headId :: HeadId
- currentSlot :: ChainSlot
- headSeed :: HeadSeed
- data CoordinatedHeadState tx = CoordinatedHeadState {
- localUTxO :: UTxOType tx
- localTxs :: [tx]
- allTxs :: Map (TxIdType tx) tx
- confirmedSnapshot :: ConfirmedSnapshot tx
- seenSnapshot :: SeenSnapshot tx
- decommitTx :: Maybe tx
- version :: SnapshotVersion
- data SeenSnapshot tx
- = NoSeenSnapshot
- | LastSeenSnapshot {
- lastSeen :: SnapshotNumber
- | RequestedSnapshot { }
- | SeenSnapshot {
- snapshot :: Snapshot tx
- signatories :: Map Party (Signature (Snapshot tx))
- seenSnapshotNumber :: SeenSnapshot tx -> SnapshotNumber
- data ClosedState tx = ClosedState {
- parameters :: HeadParameters
- confirmedSnapshot :: ConfirmedSnapshot tx
- contestationDeadline :: UTCTime
- readyToFanoutSent :: Bool
- chainState :: ChainStateType tx
- headId :: HeadId
- headSeed :: HeadSeed
- version :: SnapshotVersion
Documentation
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.
Idle (IdleState tx) | |
Initial (InitialState tx) | |
Open (OpenState tx) | |
Closed (ClosedState tx) |
Instances
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
An Idle
head only having a chain state with things seen on chain so far.
IdleState | |
|
Instances
Arbitrary (ChainStateType tx) => Arbitrary (IdleState tx) Source # | |
FromJSON (ChainStateType tx) => FromJSON (IdleState tx) Source # | |
Defined in Hydra.HeadLogic.State parseJSON :: Value -> Parser (IdleState tx) parseJSONList :: Value -> Parser [IdleState tx] omittedField :: Maybe (IdleState tx) | |
ToJSON (ChainStateType tx) => ToJSON (IdleState tx) Source # | |
Defined in Hydra.HeadLogic.State toJSON :: IdleState tx -> Value toEncoding :: IdleState tx -> Encoding toJSONList :: [IdleState tx] -> Value toEncodingList :: [IdleState tx] -> Encoding | |
Generic (IdleState tx) Source # | |
Show (ChainStateType tx) => Show (IdleState tx) Source # | |
Eq (ChainStateType tx) => Eq (IdleState tx) Source # | |
type Rep (IdleState tx) Source # | |
Defined in Hydra.HeadLogic.State |
Initial
data InitialState tx Source #
An Initial
head which already has an identity and is collecting commits.
InitialState | |
|
Instances
type PendingCommits = Set Party Source #
Open
An Open
head with a CoordinatedHeadState
tracking off-chain
transactions.
OpenState | |
|
Instances
(ArbitraryIsTx tx, Arbitrary (ChainStateType tx)) => Arbitrary (OpenState tx) Source # | |
(IsTx tx, FromJSON (ChainStateType tx)) => FromJSON (OpenState tx) Source # | |
Defined in Hydra.HeadLogic.State parseJSON :: Value -> Parser (OpenState tx) parseJSONList :: Value -> Parser [OpenState tx] omittedField :: Maybe (OpenState tx) | |
(IsTx tx, ToJSON (ChainStateType tx)) => ToJSON (OpenState tx) Source # | |
Defined in Hydra.HeadLogic.State toJSON :: OpenState tx -> Value toEncoding :: OpenState tx -> Encoding toJSONList :: [OpenState tx] -> Value toEncodingList :: [OpenState tx] -> Encoding | |
Generic (OpenState tx) Source # | |
(IsTx tx, Show (ChainStateType tx)) => Show (OpenState tx) Source # | |
(IsTx tx, Eq (ChainStateType tx)) => Eq (OpenState tx) Source # | |
type Rep (OpenState tx) Source # | |
Defined in Hydra.HeadLogic.State type Rep (OpenState tx) = D1 ('MetaData "OpenState" "Hydra.HeadLogic.State" "hydra-node-0.19.0-6Z4E5vp1s1XJuLOmmEVMTw" 'False) (C1 ('MetaCons "OpenState" 'PrefixI 'True) ((S1 ('MetaSel ('Just "parameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadParameters) :*: (S1 ('MetaSel ('Just "coordinatedHeadState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (CoordinatedHeadState tx)) :*: S1 ('MetaSel ('Just "chainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainStateType tx)))) :*: (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: (S1 ('MetaSel ('Just "currentSlot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ChainSlot) :*: S1 ('MetaSel ('Just "headSeed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadSeed))))) |
data CoordinatedHeadState tx Source #
Off-chain state of the Coordinated Head protocol.
CoordinatedHeadState | |
|
Instances
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.
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. |
|
Instances
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
.
ClosedState | |
|