Skip to content

Commit

Permalink
Update logs json schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ffakenz committed Nov 29, 2022
1 parent 3ffb2bc commit afd77f5
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 5 deletions.
98 changes: 98 additions & 0 deletions hydra-node/json-schemas/logs.yaml
Expand Up @@ -516,6 +516,25 @@ definitions:
The Party emitting the log entry.
effect:
$ref: "#/definitions/Effect"
- title: LogicOutcome
description: >-
Outcome produced, to transition the Head protocol, after processing an input event.
type: object
additionalProperties: false
required:
- tag
- by
- outcome
properties:
tag:
type: string
enum: ["LogicOutcome"]
by:
<<: { "$ref": "api.yaml#/components/schemas/Party" }
description: >-
The Party emitting the log entry.
outcome:
$ref: "#/definitions/Outcome"

LogicError:
oneOf:
Expand Down Expand Up @@ -1112,6 +1131,85 @@ definitions:
event:
$ref: "#/definitions/Event"

Outcome:
description: >-
The result of Head protocol processing Events. Each Outcome
represents an action to be taken by the node to transition
the protocol.
oneOf:
- title: OnlyEffects
type: object
additionalProperties: false
required:
- tag
- effects
description: >-
An outcome representing the list of actions to be taken by the node
to transition the protocol.
properties:
tag:
type: string
enum: ["OnlyEffects"]
effects:
type: array
items:
type: object
$ref: "#/definitions/Effect"
- title: NewState
type: object
additionalProperties: false
required:
- tag
- headState
- effects
description: >-
An outcome representing the list of actions to be taken by the node
to transition the protocol, and the new resulting state.
properties:
tag:
type: string
enum: ["NewState"]
headState:
type: object
$ref: "#/definitions/HeadState"
effects:
type: array
items:
type: object
$ref: "#/definitions/Effect"
- title: Wait
type: object
additionalProperties: false
required:
- tag
- reason
description: >-
An outcome representing the time to wait by the node before re-enqueuing
the input event to be processed again.
properties:
tag:
type: string
enum: ["Wait"]
reason:
type: object
$ref: "#/definitions/WaitReason"
- title: Error
type: object
additionalProperties: false
required:
- tag
- error
description: >-
An outcome representing an error to be logged by the node after processing
an input event.
properties:
tag:
type: string
enum: ["Error"]
error:
type: object
$ref: "#/definitions/LogicError"

WaitReason:
oneOf:
- title: WaitOnNotApplicableTx
Expand Down
8 changes: 4 additions & 4 deletions hydra-node/src/Hydra/HeadLogic.hs
Expand Up @@ -236,10 +236,10 @@ deriving instance (ToJSON (Event tx), ToJSON (HeadState tx)) => ToJSON (LogicErr
deriving instance (FromJSON (Event tx), FromJSON (HeadState tx)) => FromJSON (LogicError tx)

data Outcome tx
= OnlyEffects [Effect tx]
| NewState (HeadState tx) [Effect tx]
| Wait WaitReason
| Error (LogicError tx)
= OnlyEffects {effects :: [Effect tx]}
| NewState {headState :: HeadState tx, effects :: [Effect tx]}
| Wait {reason :: WaitReason}
| Error {error :: LogicError tx}
deriving stock (Generic)

deriving instance (IsTx tx, IsChainState tx) => Eq (Outcome tx)
Expand Down
2 changes: 1 addition & 1 deletion hydra-node/src/Hydra/Node.hs
Expand Up @@ -92,7 +92,7 @@ data HydraNodeLog tx
| EndEvent {by :: Party, event :: Event tx}
| BeginEffect {by :: Party, effect :: Effect tx}
| EndEffect {by :: Party, effect :: Effect tx}
| LogicOutcome {outcome :: Outcome tx}
| LogicOutcome {by :: Party, outcome :: Outcome tx}
deriving stock (Generic)

deriving instance (IsTx tx, IsChainState tx) => Eq (HydraNodeLog tx)
Expand Down

0 comments on commit afd77f5

Please sign in to comment.