-
Notifications
You must be signed in to change notification settings - Fork 86
/
Input.hs
34 lines (28 loc) · 1.3 KB
/
Input.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module Hydra.HeadLogic.Input where
import Hydra.Prelude
import Hydra.API.ClientInput (ClientInput)
import Hydra.Chain (ChainEvent, IsChainState)
import Hydra.Network.Message (Message, NetworkMessage)
import Hydra.Party (Party)
type TTL = Natural
-- | Inputs that are processed by the head logic (the "core"). Corresponding to
-- each of the "shell" layers, we distinguish between inputs from the client,
-- the network and the chain.
data Input tx
= -- | Input received from clients via the "Hydra.API".
ClientInput {clientInput :: ClientInput tx}
| -- | Input received from peers via a "Hydra.Network".
--
-- * `ttl` is a simple counter that's decreased every time the event is
-- reenqueued due to a wait. It's default value is `defaultTTL`
NetworkInput {ttl :: TTL, message :: NetworkMessage (Message tx)}
| -- | Input received from the chain via a "Hydra.Chain".
ChainInput {chainEvent :: ChainEvent tx}
deriving stock (Generic)
deriving stock instance IsChainState tx => Eq (Input tx)
deriving stock instance IsChainState tx => Show (Input tx)
deriving anyclass instance IsChainState tx => ToJSON (Input tx)
deriving anyclass instance IsChainState tx => FromJSON (Input tx)
instance IsChainState tx => Arbitrary (Input tx) where
arbitrary = genericArbitrary
shrink = genericShrink