{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Ouroboros.Network.Protocol.PeerSharing.Codec where
import Control.Monad.Class.MonadST
import Data.ByteString.Lazy (ByteString)
import Codec.CBOR.Read qualified as CBOR
import Network.TypedProtocol.Codec.CBOR
import Codec.CBOR.Decoding qualified as CBOR
import Codec.CBOR.Encoding qualified as CBOR
import Codec.Serialise.Class qualified as CBOR
import Ouroboros.Network.Protocol.PeerSharing.Type (ClientHasAgency (..),
Message (..), PeerSharing, ServerHasAgency (..))
import Control.Monad.Class.MonadTime.SI (DiffTime)
import Ouroboros.Network.Protocol.Limits
codecPeerSharing :: forall m peerAddress.
MonadST m
=> (peerAddress -> CBOR.Encoding)
-> (forall s . CBOR.Decoder s peerAddress)
-> Codec (PeerSharing peerAddress)
CBOR.DeserialiseFailure
m
ByteString
codecPeerSharing :: forall (m :: * -> *) peerAddress.
MonadST m =>
(peerAddress -> Encoding)
-> (forall s. Decoder s peerAddress)
-> Codec (PeerSharing peerAddress) DeserialiseFailure m ByteString
codecPeerSharing peerAddress -> Encoding
encodeAddress forall s. Decoder s peerAddress
decodeAddress = (forall (pr :: PeerRole) (st :: PeerSharing peerAddress)
(st' :: PeerSharing peerAddress).
PeerHasAgency pr st
-> Message (PeerSharing peerAddress) st st' -> Encoding)
-> (forall (pr :: PeerRole) (st :: PeerSharing peerAddress) s.
PeerHasAgency pr st -> Decoder s (SomeMessage st))
-> Codec (PeerSharing peerAddress) DeserialiseFailure m ByteString
forall ps (m :: * -> *).
MonadST m =>
(forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> Encoding)
-> (forall (pr :: PeerRole) (st :: ps) s.
PeerHasAgency pr st -> Decoder s (SomeMessage st))
-> Codec ps DeserialiseFailure m ByteString
mkCodecCborLazyBS PeerHasAgency pr st
-> Message (PeerSharing peerAddress) st st' -> Encoding
forall (pr :: PeerRole) (st :: PeerSharing peerAddress)
(st' :: PeerSharing peerAddress).
PeerHasAgency pr st
-> Message (PeerSharing peerAddress) st st' -> Encoding
encodeMsg PeerHasAgency pr st -> Decoder s (SomeMessage st)
forall (pr :: PeerRole) (st :: PeerSharing peerAddress) s.
PeerHasAgency pr st -> Decoder s (SomeMessage st)
decodeMsg
where
encodeMsg :: PeerHasAgency pr st
-> Message (PeerSharing peerAddress) st st'
-> CBOR.Encoding
encodeMsg :: forall (pr :: PeerRole) (st :: PeerSharing peerAddress)
(st' :: PeerSharing peerAddress).
PeerHasAgency pr st
-> Message (PeerSharing peerAddress) st st' -> Encoding
encodeMsg (ClientAgency ClientHasAgency st
R:ClientHasAgencyPeerSharingst (*) peerAddress st
TokIdle) (MsgShareRequest PeerSharingAmount
amount) =
Word -> Encoding
CBOR.encodeListLen Word
2
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Word -> Encoding
CBOR.encodeWord Word
0
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> PeerSharingAmount -> Encoding
forall a. Serialise a => a -> Encoding
CBOR.encode PeerSharingAmount
amount
encodeMsg (ServerAgency ServerHasAgency st
R:ServerHasAgencyPeerSharingst (*) peerAddress st
TokBusy) (MsgSharePeers [peerAddress1]
peers) =
Word -> Encoding
CBOR.encodeListLen Word
2
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Word -> Encoding
CBOR.encodeWord Word
1
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> (peerAddress -> Encoding) -> [peerAddress] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
encodeListWith peerAddress -> Encoding
encodeAddress [peerAddress]
[peerAddress1]
peers
encodeMsg (ClientAgency ClientHasAgency st
R:ClientHasAgencyPeerSharingst (*) peerAddress st
TokIdle) Message (PeerSharing peerAddress) st st'
R:MessagePeerSharingfromto (*) peerAddress st st'
MsgDone =
Word -> Encoding
CBOR.encodeListLen Word
1
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Word -> Encoding
CBOR.encodeWord Word
2
decodeMsg :: PeerHasAgency pr (st :: PeerSharing peerAddress)
-> CBOR.Decoder s (SomeMessage st)
decodeMsg :: forall (pr :: PeerRole) (st :: PeerSharing peerAddress) s.
PeerHasAgency pr st -> Decoder s (SomeMessage st)
decodeMsg PeerHasAgency pr st
stok = do
_ <- Decoder s Int
forall s. Decoder s Int
CBOR.decodeListLen
key <- CBOR.decodeWord
case (stok, key) of
(ClientAgency ClientHasAgency st
R:ClientHasAgencyPeerSharingst (*) peerAddress st
TokIdle, Word
0) -> Message (PeerSharing peerAddress) st 'StBusy -> SomeMessage st
forall ps (st :: ps) (st' :: ps).
Message ps st st' -> SomeMessage st
SomeMessage (Message (PeerSharing peerAddress) st 'StBusy -> SomeMessage st)
-> (PeerSharingAmount
-> Message (PeerSharing peerAddress) st 'StBusy)
-> PeerSharingAmount
-> SomeMessage st
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PeerSharingAmount -> Message (PeerSharing peerAddress) st 'StBusy
PeerSharingAmount
-> Message (PeerSharing peerAddress) 'StIdle 'StBusy
forall {k} (peerAddress :: k).
PeerSharingAmount
-> Message (PeerSharing peerAddress) 'StIdle 'StBusy
MsgShareRequest
(PeerSharingAmount -> SomeMessage st)
-> Decoder s PeerSharingAmount -> Decoder s (SomeMessage st)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s PeerSharingAmount
forall s. Decoder s PeerSharingAmount
forall a s. Serialise a => Decoder s a
CBOR.decode
(ServerAgency ServerHasAgency st
R:ServerHasAgencyPeerSharingst (*) peerAddress st
TokBusy, Word
1) -> Message (PeerSharing peerAddress) st 'StIdle -> SomeMessage st
forall ps (st :: ps) (st' :: ps).
Message ps st st' -> SomeMessage st
SomeMessage (Message (PeerSharing peerAddress) st 'StIdle -> SomeMessage st)
-> ([peerAddress] -> Message (PeerSharing peerAddress) st 'StIdle)
-> [peerAddress]
-> SomeMessage st
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [peerAddress] -> Message (PeerSharing peerAddress) st 'StIdle
[peerAddress] -> Message (PeerSharing peerAddress) 'StBusy 'StIdle
forall peerAddress1.
[peerAddress1]
-> Message (PeerSharing peerAddress1) 'StBusy 'StIdle
MsgSharePeers
([peerAddress] -> SomeMessage st)
-> Decoder s [peerAddress] -> Decoder s (SomeMessage st)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s peerAddress -> Decoder s [peerAddress]
forall s a. Decoder s a -> Decoder s [a]
decodeListWith Decoder s peerAddress
forall s. Decoder s peerAddress
decodeAddress
(ClientAgency ClientHasAgency st
R:ClientHasAgencyPeerSharingst (*) peerAddress st
TokIdle, Word
2) -> SomeMessage st -> Decoder s (SomeMessage st)
forall a. a -> Decoder s a
forall (m :: * -> *) a. Monad m => a -> m a
return
(SomeMessage st -> Decoder s (SomeMessage st))
-> SomeMessage st -> Decoder s (SomeMessage st)
forall a b. (a -> b) -> a -> b
$ Message (PeerSharing peerAddress) st 'StDone -> SomeMessage st
forall ps (st :: ps) (st' :: ps).
Message ps st st' -> SomeMessage st
SomeMessage Message (PeerSharing peerAddress) st 'StDone
Message (PeerSharing peerAddress) 'StIdle 'StDone
forall {k} (peerAddress :: k).
Message (PeerSharing peerAddress) 'StIdle 'StDone
MsgDone
(ClientAgency ClientHasAgency st
R:ClientHasAgencyPeerSharingst (*) peerAddress st
TokIdle, Word
_) ->
String -> Decoder s (SomeMessage st)
forall a. String -> Decoder s a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String
"codecPeerSharing.StIdle: unexpected key: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Word -> String
forall a. Show a => a -> String
show Word
key)
(ServerAgency ServerHasAgency st
R:ServerHasAgencyPeerSharingst (*) peerAddress st
TokBusy, Word
_) ->
String -> Decoder s (SomeMessage st)
forall a. String -> Decoder s a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String
"codecPeerSharing.StBusy: unexpected key: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Word -> String
forall a. Show a => a -> String
show Word
key)
encodeListWith :: (a -> CBOR.Encoding) -> [a] -> CBOR.Encoding
encodeListWith :: forall a. (a -> Encoding) -> [a] -> Encoding
encodeListWith a -> Encoding
_ [] = Word -> Encoding
CBOR.encodeListLen Word
0
encodeListWith a -> Encoding
enc [a]
xs = Encoding
CBOR.encodeListLenIndef
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> (a -> Encoding -> Encoding) -> Encoding -> [a] -> Encoding
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\a
x Encoding
r -> a -> Encoding
enc a
x Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Encoding
r) Encoding
CBOR.encodeBreak [a]
xs
decodeListWith :: CBOR.Decoder s a -> CBOR.Decoder s [a]
decodeListWith :: forall s a. Decoder s a -> Decoder s [a]
decodeListWith Decoder s a
dec= do
mn <- Decoder s (Maybe Int)
forall s. Decoder s (Maybe Int)
CBOR.decodeListLenOrIndef
case mn of
Maybe Int
Nothing -> ([a] -> a -> [a])
-> [a] -> ([a] -> [a]) -> Decoder s a -> Decoder s [a]
forall r a r' s.
(r -> a -> r) -> r -> (r -> r') -> Decoder s a -> Decoder s r'
CBOR.decodeSequenceLenIndef ((a -> [a] -> [a]) -> [a] -> a -> [a]
forall a b c. (a -> b -> c) -> b -> a -> c
flip (:)) [] [a] -> [a]
forall a. [a] -> [a]
reverse Decoder s a
dec
Just Int
n -> ([a] -> a -> [a])
-> [a] -> ([a] -> [a]) -> Int -> Decoder s a -> Decoder s [a]
forall r a r' s.
(r -> a -> r)
-> r -> (r -> r') -> Int -> Decoder s a -> Decoder s r'
CBOR.decodeSequenceLenN ((a -> [a] -> [a]) -> [a] -> a -> [a]
forall a b c. (a -> b -> c) -> b -> a -> c
flip (:)) [] [a] -> [a]
forall a. [a] -> [a]
reverse Int
n Decoder s a
dec
codecPeerSharingId
:: forall peerAddress m.
Monad m
=> Codec (PeerSharing peerAddress) CodecFailure m (AnyMessage (PeerSharing peerAddress))
codecPeerSharingId :: forall {k} (peerAddress :: k) (m :: * -> *).
Monad m =>
Codec
(PeerSharing peerAddress)
CodecFailure
m
(AnyMessage (PeerSharing peerAddress))
codecPeerSharingId = (forall (pr :: PeerRole) (st :: PeerSharing peerAddress)
(st' :: PeerSharing peerAddress).
PeerHasAgency pr st
-> Message (PeerSharing peerAddress) st st'
-> AnyMessage (PeerSharing peerAddress))
-> (forall (pr :: PeerRole) (st :: PeerSharing peerAddress).
PeerHasAgency pr st
-> m (DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st)))
-> Codec
(PeerSharing peerAddress)
CodecFailure
m
(AnyMessage (PeerSharing peerAddress))
forall ps failure (m :: * -> *) bytes.
(forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes)
-> (forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st)))
-> Codec ps failure m bytes
Codec PeerHasAgency pr st
-> Message (PeerSharing peerAddress) st st'
-> AnyMessage (PeerSharing peerAddress)
forall (pr :: PeerRole) (st :: PeerSharing peerAddress)
(st' :: PeerSharing peerAddress).
PeerHasAgency pr st
-> Message (PeerSharing peerAddress) st st'
-> AnyMessage (PeerSharing peerAddress)
encodeMsg PeerHasAgency pr st
-> m (DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st))
forall (pr :: PeerRole) (st :: PeerSharing peerAddress).
PeerHasAgency pr st
-> m (DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st))
decodeMsg
where
encodeMsg :: forall (pr :: PeerRole) st st'.
PeerHasAgency pr st
-> Message (PeerSharing peerAddress) st st'
-> AnyMessage (PeerSharing peerAddress)
encodeMsg :: forall (pr :: PeerRole) (st :: PeerSharing peerAddress)
(st' :: PeerSharing peerAddress).
PeerHasAgency pr st
-> Message (PeerSharing peerAddress) st st'
-> AnyMessage (PeerSharing peerAddress)
encodeMsg PeerHasAgency pr st
_ = Message (PeerSharing peerAddress) st st'
-> AnyMessage (PeerSharing peerAddress)
forall ps (st :: ps) (st' :: ps).
Message ps st st' -> AnyMessage ps
AnyMessage
decodeMsg :: forall (pr :: PeerRole) (st :: (PeerSharing peerAddress)).
PeerHasAgency pr st
-> m (DecodeStep (AnyMessage (PeerSharing peerAddress))
CodecFailure m (SomeMessage st))
decodeMsg :: forall (pr :: PeerRole) (st :: PeerSharing peerAddress).
PeerHasAgency pr st
-> m (DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st))
decodeMsg PeerHasAgency pr st
stok = DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st)
-> m (DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st))
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st)
-> m (DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st)))
-> DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st)
-> m (DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st))
forall a b. (a -> b) -> a -> b
$ (Maybe (AnyMessage (PeerSharing peerAddress))
-> m (DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st)))
-> DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st)
forall bytes failure (m :: * -> *) a.
(Maybe bytes -> m (DecodeStep bytes failure m a))
-> DecodeStep bytes failure m a
DecodePartial ((Maybe (AnyMessage (PeerSharing peerAddress))
-> m (DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st)))
-> DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st))
-> (Maybe (AnyMessage (PeerSharing peerAddress))
-> m (DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st)))
-> DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st)
forall a b. (a -> b) -> a -> b
$ \Maybe (AnyMessage (PeerSharing peerAddress))
bytes -> DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st)
-> m (DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st))
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st)
-> m (DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st)))
-> DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st)
-> m (DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st))
forall a b. (a -> b) -> a -> b
$
case (PeerHasAgency pr st
stok, Maybe (AnyMessage (PeerSharing peerAddress))
bytes) of
(ClientAgency ClientHasAgency st
R:ClientHasAgencyPeerSharingst k peerAddress st
TokIdle, Just (AnyMessage msg :: Message (PeerSharing peerAddress) st st'
msg@(MsgShareRequest {})))
-> SomeMessage st
-> Maybe (AnyMessage (PeerSharing peerAddress))
-> DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st)
forall bytes failure (m :: * -> *) a.
a -> Maybe bytes -> DecodeStep bytes failure m a
DecodeDone (Message (PeerSharing peerAddress) st st' -> SomeMessage st
forall ps (st :: ps) (st' :: ps).
Message ps st st' -> SomeMessage st
SomeMessage Message (PeerSharing peerAddress) st st'
Message (PeerSharing peerAddress) st st'
msg) Maybe (AnyMessage (PeerSharing peerAddress))
forall a. Maybe a
Nothing
(ServerAgency ServerHasAgency st
R:ServerHasAgencyPeerSharingst k peerAddress st
TokBusy, Just (AnyMessage msg :: Message (PeerSharing peerAddress) st st'
msg@(MsgSharePeers {})))
-> SomeMessage st
-> Maybe (AnyMessage (PeerSharing peerAddress))
-> DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st)
forall bytes failure (m :: * -> *) a.
a -> Maybe bytes -> DecodeStep bytes failure m a
DecodeDone (Message (PeerSharing peerAddress) st st' -> SomeMessage st
forall ps (st :: ps) (st' :: ps).
Message ps st st' -> SomeMessage st
SomeMessage Message (PeerSharing peerAddress) st st'
Message (PeerSharing peerAddress) st st'
msg) Maybe (AnyMessage (PeerSharing peerAddress))
forall a. Maybe a
Nothing
(ClientAgency ClientHasAgency st
R:ClientHasAgencyPeerSharingst k peerAddress st
TokIdle, Just (AnyMessage msg :: Message (PeerSharing peerAddress) st st'
msg@(Message (PeerSharing peerAddress) st st'
R:MessagePeerSharingfromto k peerAddress st st'
MsgDone)))
-> SomeMessage st
-> Maybe (AnyMessage (PeerSharing peerAddress))
-> DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st)
forall bytes failure (m :: * -> *) a.
a -> Maybe bytes -> DecodeStep bytes failure m a
DecodeDone (Message (PeerSharing peerAddress) st st' -> SomeMessage st
forall ps (st :: ps) (st' :: ps).
Message ps st st' -> SomeMessage st
SomeMessage Message (PeerSharing peerAddress) st st'
Message (PeerSharing peerAddress) st st'
msg) Maybe (AnyMessage (PeerSharing peerAddress))
forall a. Maybe a
Nothing
(PeerHasAgency pr st
_, Maybe (AnyMessage (PeerSharing peerAddress))
_) -> CodecFailure
-> DecodeStep
(AnyMessage (PeerSharing peerAddress))
CodecFailure
m
(SomeMessage st)
forall bytes failure (m :: * -> *) a.
failure -> DecodeStep bytes failure m a
DecodeFail (String -> CodecFailure
CodecFailure String
"codecPeerSharingId: no matching message")
maxTransmissionUnit :: Word
maxTransmissionUnit :: Word
maxTransmissionUnit = Word
4 Word -> Word -> Word
forall a. Num a => a -> a -> a
* Word
1440
byteLimitsPeerSharing :: (bytes -> Word)
-> ProtocolSizeLimits (PeerSharing peerAddress) bytes
byteLimitsPeerSharing :: forall {k} bytes (peerAddress :: k).
(bytes -> Word)
-> ProtocolSizeLimits (PeerSharing peerAddress) bytes
byteLimitsPeerSharing = (forall (pr :: PeerRole) (st :: PeerSharing peerAddress).
PeerHasAgency pr st -> Word)
-> (bytes -> Word)
-> ProtocolSizeLimits (PeerSharing peerAddress) bytes
forall ps bytes.
(forall (pr :: PeerRole) (st :: ps). PeerHasAgency pr st -> Word)
-> (bytes -> Word) -> ProtocolSizeLimits ps bytes
ProtocolSizeLimits PeerHasAgency pr st -> Word
forall {k} (pr :: PeerRole) (peerAddress :: k)
(st :: PeerSharing peerAddress).
PeerHasAgency pr st -> Word
forall (pr :: PeerRole) (st :: PeerSharing peerAddress).
PeerHasAgency pr st -> Word
sizeLimitForState
where
sizeLimitForState :: PeerHasAgency (pr :: PeerRole)
(st :: PeerSharing peerAddress)
-> Word
sizeLimitForState :: forall {k} (pr :: PeerRole) (peerAddress :: k)
(st :: PeerSharing peerAddress).
PeerHasAgency pr st -> Word
sizeLimitForState (ClientAgency ClientHasAgency st
R:ClientHasAgencyPeerSharingst k peerAddress st
TokIdle) = Word
maxTransmissionUnit
sizeLimitForState (ServerAgency ServerHasAgency st
R:ServerHasAgencyPeerSharingst k peerAddress st
TokBusy) = Word
maxTransmissionUnit
timeLimitsPeerSharing :: ProtocolTimeLimits (PeerSharing peerAddress)
timeLimitsPeerSharing :: forall {k} (peerAddress :: k).
ProtocolTimeLimits (PeerSharing peerAddress)
timeLimitsPeerSharing = ProtocolTimeLimits { PeerHasAgency pr st -> Maybe DiffTime
forall {k} (pr :: PeerRole) (peerAddress :: k)
(st :: PeerSharing peerAddress).
PeerHasAgency pr st -> Maybe DiffTime
forall (pr :: PeerRole) (st :: PeerSharing peerAddress).
PeerHasAgency pr st -> Maybe DiffTime
timeLimitForState :: forall {k} (pr :: PeerRole) (peerAddress :: k)
(st :: PeerSharing peerAddress).
PeerHasAgency pr st -> Maybe DiffTime
timeLimitForState :: forall (pr :: PeerRole) (st :: PeerSharing peerAddress).
PeerHasAgency pr st -> Maybe DiffTime
timeLimitForState }
where
timeLimitForState :: PeerHasAgency (pr :: PeerRole)
(st :: PeerSharing peerAddress)
-> Maybe DiffTime
timeLimitForState :: forall {k} (pr :: PeerRole) (peerAddress :: k)
(st :: PeerSharing peerAddress).
PeerHasAgency pr st -> Maybe DiffTime
timeLimitForState (ClientAgency ClientHasAgency st
R:ClientHasAgencyPeerSharingst k peerAddress st
TokIdle) = Maybe DiffTime
waitForever
timeLimitForState (ServerAgency ServerHasAgency st
R:ServerHasAgencyPeerSharingst k peerAddress st
TokBusy) = Maybe DiffTime
longWait