6
6
{-# LANGUAGE RankNTypes #-}
7
7
{-# LANGUAGE ScopedTypeVariables #-}
8
8
9
- module Ouroboros.Network.Protocol.PeerSharing.Codec where
9
+ module Ouroboros.Network.Protocol.PeerSharing.Codec
10
+ ( codecPeerSharing
11
+ , codecPeerSharingId
12
+ , byteLimitsPeerSharing
13
+ , timeLimitsPeerSharing
14
+ ) where
10
15
11
16
import Control.Monad.Class.MonadST
12
17
import Control.Monad.Class.MonadTime.SI (DiffTime )
13
18
14
19
import Data.ByteString.Lazy (ByteString )
20
+ import Data.Kind (Type )
15
21
16
22
import Codec.CBOR.Decoding qualified as CBOR
17
23
import Codec.CBOR.Encoding qualified as CBOR
@@ -23,7 +29,7 @@ import Network.TypedProtocol.Codec.CBOR
23
29
import Ouroboros.Network.Protocol.Limits
24
30
import Ouroboros.Network.Protocol.PeerSharing.Type
25
31
26
- codecPeerSharing :: forall m peerAddress .
32
+ codecPeerSharing :: forall m ( peerAddress :: Type ) .
27
33
MonadST m
28
34
=> (peerAddress -> CBOR. Encoding )
29
35
-- ^ encode 'peerAddress'
@@ -87,7 +93,7 @@ codecPeerSharing encodeAddress decodeAddress = mkCodecCborLazyBS encodeMsg decod
87
93
Just n -> CBOR. decodeSequenceLenN (flip (:) ) [] reverse n dec
88
94
89
95
codecPeerSharingId
90
- :: forall peerAddress m .
96
+ :: forall ( peerAddress :: Type ) m .
91
97
Monad m
92
98
=> Codec (PeerSharing peerAddress ) CodecFailure m (AnyMessage (PeerSharing peerAddress ))
93
99
codecPeerSharingId = Codec encodeMsg decodeMsg
@@ -121,7 +127,7 @@ codecPeerSharingId = Codec encodeMsg decodeMsg
121
127
maxTransmissionUnit :: Word
122
128
maxTransmissionUnit = 4 * 1440
123
129
124
- byteLimitsPeerSharing :: forall peerAddress bytes .
130
+ byteLimitsPeerSharing :: forall ( peerAddress :: Type ) bytes .
125
131
(bytes -> Word ) -- ^ compute size of bytes
126
132
-> ProtocolSizeLimits (PeerSharing peerAddress ) bytes
127
133
byteLimitsPeerSharing = ProtocolSizeLimits sizeLimitForState
@@ -144,6 +150,7 @@ byteLimitsPeerSharing = ProtocolSizeLimits sizeLimitForState
144
150
-- | `StBusy` | `longWait` |
145
151
-- +----------------------+---------------+
146
152
--
153
+ timeLimitsPeerSharing :: forall (peerAddress :: Type ). ProtocolTimeLimits (PeerSharing peerAddress )
147
154
timeLimitsPeerSharing = ProtocolTimeLimits { timeLimitForState }
148
155
where
149
156
timeLimitForState :: forall (st :: PeerSharing peerAddress ).
0 commit comments