/
Combinators.hs
65 lines (51 loc) · 2.73 KB
/
Combinators.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
module Cardano.TraceDispatcher.Network.Combinators
(
severityTChainSync
, namesForTChainSync
) where
import Cardano.Logging
import Cardano.Prelude
import Ouroboros.Network.Block (Point, Serialised, Tip)
import qualified Ouroboros.Network.BlockFetch.ClientState as BlockFetch
import Ouroboros.Network.Codec (AnyMessageAndAgency (..))
import Ouroboros.Network.Driver.Simple (TraceSendRecv (..))
import Ouroboros.Network.Protocol.ChainSync.Type (ChainSync (..),
Message (..))
severityTChainSync :: BlockFetch.TraceLabelPeer peer (TraceSendRecv
(ChainSync (Serialised blk) (Point blk) (Tip blk))) -> SeverityS
severityTChainSync (BlockFetch.TraceLabelPeer _ v) = severityTChainSync' v
where
severityTChainSync' (TraceSendMsg msg) = severityTChainSync'' msg
severityTChainSync' (TraceRecvMsg msg) = severityTChainSync'' msg
severityTChainSync'' (AnyMessageAndAgency _agency msg) = severityTChainSync''' msg
severityTChainSync''' :: Message
(ChainSync header point tip) from to
-> SeverityS
severityTChainSync''' MsgRequestNext {} = Info
severityTChainSync''' MsgAwaitReply {} = Info
severityTChainSync''' MsgRollForward {} = Info
severityTChainSync''' MsgRollBackward {} = Info
severityTChainSync''' MsgFindIntersect {} = Info
severityTChainSync''' MsgIntersectFound {} = Info
severityTChainSync''' MsgIntersectNotFound {} = Info
severityTChainSync''' MsgDone {} = Info
namesForTChainSync :: BlockFetch.TraceLabelPeer peer (TraceSendRecv
(ChainSync (Serialised blk) (Point blk) (Tip blk))) -> [Text]
namesForTChainSync (BlockFetch.TraceLabelPeer _ v) = namesTChainSync v
where
namesTChainSync (TraceSendMsg msg) = "Send" : namesTChainSync' msg
namesTChainSync (TraceRecvMsg msg) = "Recieve" : namesTChainSync' msg
namesTChainSync' (AnyMessageAndAgency _agency msg) = namesTChainSync'' msg
namesTChainSync'' :: Message
(ChainSync header point tip) from to
-> [Text]
namesTChainSync'' MsgRequestNext {} = ["RequestNext"]
namesTChainSync'' MsgAwaitReply {} = ["AwaitReply"]
namesTChainSync'' MsgRollForward {} = ["RollForward"]
namesTChainSync'' MsgRollBackward {} = ["RollBackward"]
namesTChainSync'' MsgFindIntersect {} = ["FindIntersect"]
namesTChainSync'' MsgIntersectFound {} = ["IntersectFound"]
namesTChainSync'' MsgIntersectNotFound {} = ["IntersectNotFound"]
namesTChainSync'' MsgDone {} = ["Done"]