Skip to content

Commit

Permalink
Add headId to HeadStatus and thus including it into Greetings
Browse files Browse the repository at this point in the history
  • Loading branch information
ffakenz committed Sep 11, 2024
1 parent 7025d78 commit cb31493
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 18 deletions.
78 changes: 70 additions & 8 deletions hydra-node/json-schemas/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1299,14 +1299,76 @@ components:
contentEncoding: base16

HeadStatus:
type: string
enum:
- Idle
- Initializing
- Open
- Closed
- FanoutPossible
- Final
oneOf:
- title: "Idle"
type: object
additionalProperties: false
required:
- tag
properties:
tag:
type: string
enum: ["Idle"]
- title: "Initializing"
type: object
additionalProperties: false
required:
- headId
- tag
properties:
headId:
$ref: "api.yaml#/components/schemas/HeadId"
tag:
type: string
enum: ["Initializing"]
- title: "Open"
type: object
additionalProperties: false
required:
- headId
- tag
properties:
headId:
$ref: "api.yaml#/components/schemas/HeadId"
tag:
type: string
enum: ["InitialSnapshot"]
- title: "Closed"
type: object
additionalProperties: false
required:
- headId
- tag
properties:
headId:
$ref: "api.yaml#/components/schemas/HeadId"
tag:
type: string
enum: ["Closed"]
- title: "FanoutPossible"
type: object
additionalProperties: false
required:
- headId
- tag
properties:
headId:
$ref: "api.yaml#/components/schemas/HeadId"
tag:
type: string
enum: ["FanoutPossible"]
- title: "Final"
type: object
additionalProperties: false
required:
- headId
- tag
properties:
headId:
$ref: "api.yaml#/components/schemas/HeadId"
tag:
type: string
enum: ["Final"]

MultiSignature:
type: object
Expand Down
20 changes: 10 additions & 10 deletions hydra-node/src/Hydra/API/ServerOutput.hs
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,11 @@ prepareServerOutput ServerOutputConfig{utxoInSnapshot} response =
-- | All possible Hydra states displayed in the API server outputs.
data HeadStatus
= Idle
| Initializing
| Open
| Closed
| FanoutPossible
| Final
| Initializing {headId :: HeadId}
| Open {headId :: HeadId}
| Closed {headId :: HeadId}
| FanoutPossible {headId :: HeadId}
| Final {headId :: HeadId}
deriving stock (Eq, Show, Generic)
deriving anyclass (ToJSON, FromJSON)

Expand All @@ -274,11 +274,11 @@ projectInitializingHeadId mHeadId = \case
-- | Projection function related to 'headStatus' field in 'Greetings' message.
projectHeadStatus :: HeadStatus -> ServerOutput tx -> HeadStatus
projectHeadStatus headStatus = \case
HeadIsInitializing{} -> Initializing
HeadIsOpen{} -> Open
HeadIsClosed{} -> Closed
ReadyToFanout{} -> FanoutPossible
HeadIsFinalized{} -> Final
HeadIsInitializing{headId} -> Initializing{headId}
HeadIsOpen{headId} -> Open{headId}
HeadIsClosed{headId} -> Closed{headId}
ReadyToFanout{headId} -> FanoutPossible{headId}
HeadIsFinalized{headId} -> Final{headId}
_other -> headStatus

-- | Projection of latest confirmed snapshot UTxO.
Expand Down

0 comments on commit cb31493

Please sign in to comment.