{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE TypeApplications #-}
module Ouroboros.Network.TxSubmission.Inbound.V2.Policy
( TxDecisionPolicy (..)
, mkTxDecisionPolicy
, saneTxDecisionPolicy
, TxConfigurationError (..)
, TxSubmissionConfig (..)
, defaultTxSubmissionConfigV2
, max_TX_SIZE
, max_TXID_SIZE
, NumTxIdsToReq (..)
) where
import Control.DeepSeq
import Control.Exception (Exception)
import Control.Monad (unless)
import Control.Monad.Class.MonadTime.SI
import Ouroboros.Network.Protocol.Limits (sizeLimitForState)
import Ouroboros.Network.Protocol.TxSubmission2.Codec (byteLimitsTxSubmission2)
import Ouroboros.Network.Protocol.TxSubmission2.Type (NumTxIdsToAck (..),
NumTxIdsToReq (..), SingTxSubmission (SingIdle, SingTxs))
import Ouroboros.Network.SizeInBytes (SizeInBytes (..))
import Ouroboros.Network.TxSubmission.Inbound.V2.Types
(const_MAX_TX_SIZE_DISCREPANCY)
max_TX_SIZE :: SizeInBytes
max_TX_SIZE :: SizeInBytes
max_TX_SIZE = SizeInBytes
65_540
max_TXID_SIZE :: SizeInBytes
max_TXID_SIZE :: SizeInBytes
max_TXID_SIZE = SizeInBytes
44
data TxDecisionPolicy = TxDecisionPolicy {
TxDecisionPolicy -> SizeInBytes
txsSizeInflightPerPeer :: !SizeInBytes,
TxDecisionPolicy -> SizeInBytes
txsSizePerBatch :: !SizeInBytes,
TxDecisionPolicy -> Int
maxOutstandingTxBatchesPerPeer :: !Int,
TxDecisionPolicy -> Int
txInflightMultiplicity :: !Int,
TxDecisionPolicy -> DiffTime
bufferedTxsMinLifetime :: !DiffTime,
TxDecisionPolicy -> Double
scoreRate :: !Double,
TxDecisionPolicy -> Double
scoreMax :: !Double,
TxDecisionPolicy -> Double
scoreAcceptDecrement :: !Double,
TxDecisionPolicy -> DiffTime
interTxSpace :: !DiffTime,
TxDecisionPolicy -> DiffTime
inflightTimeout :: !DiffTime,
TxDecisionPolicy -> DiffTime
maxPeerClaimDelay :: !DiffTime,
TxDecisionPolicy -> Bool
disablePipelinedTxIdRequests :: !Bool
}
deriving (TxDecisionPolicy -> TxDecisionPolicy -> Bool
(TxDecisionPolicy -> TxDecisionPolicy -> Bool)
-> (TxDecisionPolicy -> TxDecisionPolicy -> Bool)
-> Eq TxDecisionPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TxDecisionPolicy -> TxDecisionPolicy -> Bool
== :: TxDecisionPolicy -> TxDecisionPolicy -> Bool
$c/= :: TxDecisionPolicy -> TxDecisionPolicy -> Bool
/= :: TxDecisionPolicy -> TxDecisionPolicy -> Bool
Eq, Int -> TxDecisionPolicy -> ShowS
[TxDecisionPolicy] -> ShowS
TxDecisionPolicy -> String
(Int -> TxDecisionPolicy -> ShowS)
-> (TxDecisionPolicy -> String)
-> ([TxDecisionPolicy] -> ShowS)
-> Show TxDecisionPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TxDecisionPolicy -> ShowS
showsPrec :: Int -> TxDecisionPolicy -> ShowS
$cshow :: TxDecisionPolicy -> String
show :: TxDecisionPolicy -> String
$cshowList :: [TxDecisionPolicy] -> ShowS
showList :: [TxDecisionPolicy] -> ShowS
Show)
instance NFData TxDecisionPolicy where
rnf :: TxDecisionPolicy -> ()
rnf TxDecisionPolicy{} = ()
mkTxDecisionPolicy
:: TxSubmissionConfig
-> Either TxConfigurationError TxDecisionPolicy
mkTxDecisionPolicy :: TxSubmissionConfig -> Either TxConfigurationError TxDecisionPolicy
mkTxDecisionPolicy TxSubmissionConfig
config =
TxDecisionPolicy
policy TxDecisionPolicy
-> Either TxConfigurationError ()
-> Either TxConfigurationError TxDecisionPolicy
forall a b.
a -> Either TxConfigurationError b -> Either TxConfigurationError a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ TxDecisionPolicy
-> TxSubmissionConfig -> Either TxConfigurationError ()
saneTxDecisionPolicy TxDecisionPolicy
policy TxSubmissionConfig
config
where
policy :: TxDecisionPolicy
policy = TxDecisionPolicy {
txsSizeInflightPerPeer :: SizeInBytes
txsSizeInflightPerPeer =
forall a b. (Integral a, Num b) => a -> b
fromIntegral @Integer @SizeInBytes
(Integer -> SizeInBytes) -> Integer -> SizeInBytes
forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> Integer
forall a. Ord a => a -> a -> a
min (SizeInBytes -> Integer
forall a. Integral a => a -> Integer
toInteger (SizeInBytes
forall a. Bounded a => a
maxBound :: SizeInBytes))
(SizeInBytes -> Integer
forall a. Integral a => a -> Integer
toInteger SizeInBytes
max_TX_SIZE Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* NumTxIdsToReq -> Integer
forall a. Integral a => a -> Integer
toInteger (TxSubmissionConfig -> NumTxIdsToReq
maxNumTxIdsToRequest TxSubmissionConfig
config)),
txsSizePerBatch :: SizeInBytes
txsSizePerBatch =
SizeInBytes -> SizeInBytes
safeLimit
(SizeInBytes -> SizeInBytes) -> SizeInBytes -> SizeInBytes
forall a b. (a -> b) -> a -> b
$ Word -> SizeInBytes
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
stTxsSizeLimit
SizeInBytes -> SizeInBytes -> SizeInBytes
forall a. Num a => a -> a -> a
- SizeInBytes
msgReplyTxsFraming,
maxOutstandingTxBatchesPerPeer :: Int
maxOutstandingTxBatchesPerPeer = Int
4,
txInflightMultiplicity :: Int
txInflightMultiplicity = Int
2,
bufferedTxsMinLifetime :: DiffTime
bufferedTxsMinLifetime = DiffTime
2,
scoreRate :: Double
scoreRate = Double
0.001,
scoreMax :: Double
scoreMax = Double
15 Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
60,
scoreAcceptDecrement :: Double
scoreAcceptDecrement = Double
3,
interTxSpace :: DiffTime
interTxSpace = DiffTime
0.250,
inflightTimeout :: DiffTime
inflightTimeout = DiffTime
0.600,
maxPeerClaimDelay :: DiffTime
maxPeerClaimDelay = DiffTime
0.250,
disablePipelinedTxIdRequests :: Bool
disablePipelinedTxIdRequests = Bool
False
}
safeLimit :: SizeInBytes -> SizeInBytes
safeLimit :: SizeInBytes -> SizeInBytes
safeLimit SizeInBytes
limit = SizeInBytes
limit SizeInBytes -> SizeInBytes -> SizeInBytes
forall a. Num a => a -> a -> a
- SizeInBytes
limit SizeInBytes -> SizeInBytes -> SizeInBytes
forall a. Integral a => a -> a -> a
`div` SizeInBytes
50
msgReplyTxsFraming :: SizeInBytes
msgReplyTxsFraming :: SizeInBytes
msgReplyTxsFraming = SizeInBytes
4
msgRequestTxsFraming :: SizeInBytes
msgRequestTxsFraming :: SizeInBytes
msgRequestTxsFraming = SizeInBytes
4
stTxsSizeLimit :: Word
stTxsSizeLimit :: Word
stTxsSizeLimit =
ProtocolSizeLimits
(TxSubmission2 (ZonkAny 2) (ZonkAny 3)) (ZonkAny 5)
-> forall (st :: TxSubmission2 (ZonkAny 2) (ZonkAny 3)).
ActiveState st =>
StateToken st -> Word
forall ps bytes.
ProtocolSizeLimits ps bytes
-> forall (st :: ps). ActiveState st => StateToken st -> Word
sizeLimitForState
((ZonkAny 5 -> Word)
-> ProtocolSizeLimits
(TxSubmission2 (ZonkAny 2) (ZonkAny 3)) (ZonkAny 5)
forall bytes txid tx.
(bytes -> Word) -> ProtocolSizeLimits (TxSubmission2 txid tx) bytes
byteLimitsTxSubmission2 (String -> ZonkAny 5 -> Word
forall a. HasCallStack => String -> a
error String
"invariant violation!"))
StateToken 'StTxs
SingTxSubmission 'StTxs
forall {txid} {tx}. SingTxSubmission 'StTxs
SingTxs
stIdleSizeLimit :: Word
stIdleSizeLimit :: Word
stIdleSizeLimit =
ProtocolSizeLimits
(TxSubmission2 (ZonkAny 0) (ZonkAny 1)) (ZonkAny 4)
-> forall (st :: TxSubmission2 (ZonkAny 0) (ZonkAny 1)).
ActiveState st =>
StateToken st -> Word
forall ps bytes.
ProtocolSizeLimits ps bytes
-> forall (st :: ps). ActiveState st => StateToken st -> Word
sizeLimitForState
((ZonkAny 4 -> Word)
-> ProtocolSizeLimits
(TxSubmission2 (ZonkAny 0) (ZonkAny 1)) (ZonkAny 4)
forall bytes txid tx.
(bytes -> Word) -> ProtocolSizeLimits (TxSubmission2 txid tx) bytes
byteLimitsTxSubmission2 (String -> ZonkAny 4 -> Word
forall a. HasCallStack => String -> a
error String
"invariant violation!"))
StateToken 'StIdle
SingTxSubmission 'StIdle
forall {txid} {tx}. SingTxSubmission 'StIdle
SingIdle
data TxSubmissionConfig =
TxSubmissionConfig {
TxSubmissionConfig -> NumTxIdsToAck
maxNumUnacknowledgedTxIds :: !NumTxIdsToAck,
TxSubmissionConfig -> NumTxIdsToReq
maxNumTxIdsToRequest :: !NumTxIdsToReq
}
deriving (TxSubmissionConfig -> TxSubmissionConfig -> Bool
(TxSubmissionConfig -> TxSubmissionConfig -> Bool)
-> (TxSubmissionConfig -> TxSubmissionConfig -> Bool)
-> Eq TxSubmissionConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TxSubmissionConfig -> TxSubmissionConfig -> Bool
== :: TxSubmissionConfig -> TxSubmissionConfig -> Bool
$c/= :: TxSubmissionConfig -> TxSubmissionConfig -> Bool
/= :: TxSubmissionConfig -> TxSubmissionConfig -> Bool
Eq, Int -> TxSubmissionConfig -> ShowS
[TxSubmissionConfig] -> ShowS
TxSubmissionConfig -> String
(Int -> TxSubmissionConfig -> ShowS)
-> (TxSubmissionConfig -> String)
-> ([TxSubmissionConfig] -> ShowS)
-> Show TxSubmissionConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TxSubmissionConfig -> ShowS
showsPrec :: Int -> TxSubmissionConfig -> ShowS
$cshow :: TxSubmissionConfig -> String
show :: TxSubmissionConfig -> String
$cshowList :: [TxSubmissionConfig] -> ShowS
showList :: [TxSubmissionConfig] -> ShowS
Show)
instance NFData TxSubmissionConfig where
rnf :: TxSubmissionConfig -> ()
rnf TxSubmissionConfig{} = ()
defaultTxSubmissionConfigV2 :: TxSubmissionConfig
defaultTxSubmissionConfigV2 :: TxSubmissionConfig
defaultTxSubmissionConfigV2 = TxSubmissionConfig {
maxNumUnacknowledgedTxIds :: NumTxIdsToAck
maxNumUnacknowledgedTxIds = Word16 -> NumTxIdsToAck
NumTxIdsToAck Word16
10,
maxNumTxIdsToRequest :: NumTxIdsToReq
maxNumTxIdsToRequest = Word16 -> NumTxIdsToReq
NumTxIdsToReq Word16
6
}
data TxConfigurationError
= NumUnacknowledgedTxIdsTooSmall NumTxIdsToAck
| NumUnacknowledgedTxIdsTooLarge NumTxIdsToAck
| MaxNumTxIdsToRequestTooSmall NumTxIdsToReq
| MaxNumTxIdsToRequestTooLarge NumTxIdsToReq
| TxsSizeInflightPerPeerTooSmall SizeInBytes
| TxsSizePerBatchTooSmall SizeInBytes
| TxsSizePerBatchTooLarge SizeInBytes NumTxIdsToAck
| MaxOutstandingTxBatchesPerPeerTooSmall Int
| TxInflightMultiplicityTooSmall Int
| BufferedTxsMinLifetimeTooSmall DiffTime
| ScoreRateTooSmall Double
| ScoreMaxTooSmall Double
| ScoreAcceptDecrementTooSmall Double
| InterTxSpaceTooSmall DiffTime
| InflightTimeoutTooSmall DiffTime DiffTime
| MaxPeerClaimDelayTooSmall DiffTime
deriving (TxConfigurationError -> TxConfigurationError -> Bool
(TxConfigurationError -> TxConfigurationError -> Bool)
-> (TxConfigurationError -> TxConfigurationError -> Bool)
-> Eq TxConfigurationError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TxConfigurationError -> TxConfigurationError -> Bool
== :: TxConfigurationError -> TxConfigurationError -> Bool
$c/= :: TxConfigurationError -> TxConfigurationError -> Bool
/= :: TxConfigurationError -> TxConfigurationError -> Bool
Eq, Int -> TxConfigurationError -> ShowS
[TxConfigurationError] -> ShowS
TxConfigurationError -> String
(Int -> TxConfigurationError -> ShowS)
-> (TxConfigurationError -> String)
-> ([TxConfigurationError] -> ShowS)
-> Show TxConfigurationError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TxConfigurationError -> ShowS
showsPrec :: Int -> TxConfigurationError -> ShowS
$cshow :: TxConfigurationError -> String
show :: TxConfigurationError -> String
$cshowList :: [TxConfigurationError] -> ShowS
showList :: [TxConfigurationError] -> ShowS
Show)
instance Exception TxConfigurationError
saneTxDecisionPolicy :: TxDecisionPolicy
-> TxSubmissionConfig
-> Either TxConfigurationError ()
saneTxDecisionPolicy :: TxDecisionPolicy
-> TxSubmissionConfig -> Either TxConfigurationError ()
saneTxDecisionPolicy TxDecisionPolicy {
SizeInBytes
txsSizeInflightPerPeer :: TxDecisionPolicy -> SizeInBytes
txsSizeInflightPerPeer :: SizeInBytes
txsSizeInflightPerPeer,
SizeInBytes
txsSizePerBatch :: TxDecisionPolicy -> SizeInBytes
txsSizePerBatch :: SizeInBytes
txsSizePerBatch,
Int
maxOutstandingTxBatchesPerPeer :: TxDecisionPolicy -> Int
maxOutstandingTxBatchesPerPeer :: Int
maxOutstandingTxBatchesPerPeer,
Int
txInflightMultiplicity :: TxDecisionPolicy -> Int
txInflightMultiplicity :: Int
txInflightMultiplicity,
DiffTime
bufferedTxsMinLifetime :: TxDecisionPolicy -> DiffTime
bufferedTxsMinLifetime :: DiffTime
bufferedTxsMinLifetime,
Double
scoreRate :: TxDecisionPolicy -> Double
scoreRate :: Double
scoreRate,
Double
scoreMax :: TxDecisionPolicy -> Double
scoreMax :: Double
scoreMax,
Double
scoreAcceptDecrement :: TxDecisionPolicy -> Double
scoreAcceptDecrement :: Double
scoreAcceptDecrement,
DiffTime
interTxSpace :: TxDecisionPolicy -> DiffTime
interTxSpace :: DiffTime
interTxSpace,
DiffTime
inflightTimeout :: TxDecisionPolicy -> DiffTime
inflightTimeout :: DiffTime
inflightTimeout,
DiffTime
maxPeerClaimDelay :: TxDecisionPolicy -> DiffTime
maxPeerClaimDelay :: DiffTime
maxPeerClaimDelay
}
TxSubmissionConfig {
NumTxIdsToAck
maxNumUnacknowledgedTxIds :: TxSubmissionConfig -> NumTxIdsToAck
maxNumUnacknowledgedTxIds :: NumTxIdsToAck
maxNumUnacknowledgedTxIds,
NumTxIdsToReq
maxNumTxIdsToRequest :: TxSubmissionConfig -> NumTxIdsToReq
maxNumTxIdsToRequest :: NumTxIdsToReq
maxNumTxIdsToRequest
} = do
Bool
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (NumTxIdsToAck
maxNumUnacknowledgedTxIds NumTxIdsToAck -> NumTxIdsToAck -> Bool
forall a. Ord a => a -> a -> Bool
>= NumTxIdsToAck
1)
(Either TxConfigurationError () -> Either TxConfigurationError ())
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall a b. (a -> b) -> a -> b
$ TxConfigurationError -> Either TxConfigurationError ()
forall a b. a -> Either a b
Left (NumTxIdsToAck -> TxConfigurationError
NumUnacknowledgedTxIdsTooSmall NumTxIdsToAck
maxNumUnacknowledgedTxIds)
Bool
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ( SizeInBytes -> Integer
forall a. Integral a => a -> Integer
toInteger SizeInBytes
msgRequestTxsFraming
Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ SizeInBytes -> Integer
forall a. Integral a => a -> Integer
toInteger SizeInBytes
max_TXID_SIZE Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* NumTxIdsToAck -> Integer
forall a. Integral a => a -> Integer
toInteger NumTxIdsToAck
maxNumUnacknowledgedTxIds
Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
<= Word -> Integer
forall a. Integral a => a -> Integer
toInteger Word
stIdleSizeLimit)
(Either TxConfigurationError () -> Either TxConfigurationError ())
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall a b. (a -> b) -> a -> b
$ TxConfigurationError -> Either TxConfigurationError ()
forall a b. a -> Either a b
Left (NumTxIdsToAck -> TxConfigurationError
NumUnacknowledgedTxIdsTooLarge NumTxIdsToAck
maxNumUnacknowledgedTxIds)
Bool
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (NumTxIdsToReq
maxNumTxIdsToRequest NumTxIdsToReq -> NumTxIdsToReq -> Bool
forall a. Ord a => a -> a -> Bool
>= NumTxIdsToReq
1)
(Either TxConfigurationError () -> Either TxConfigurationError ())
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall a b. (a -> b) -> a -> b
$ TxConfigurationError -> Either TxConfigurationError ()
forall a b. a -> Either a b
Left (NumTxIdsToReq -> TxConfigurationError
MaxNumTxIdsToRequestTooSmall NumTxIdsToReq
maxNumTxIdsToRequest)
Bool
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ( SizeInBytes -> Integer
forall a. Integral a => a -> Integer
toInteger SizeInBytes
max_TX_SIZE Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* NumTxIdsToReq -> Integer
forall a. Integral a => a -> Integer
toInteger NumTxIdsToReq
maxNumTxIdsToRequest
Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
<= SizeInBytes -> Integer
forall a. Integral a => a -> Integer
toInteger (SizeInBytes
forall a. Bounded a => a
maxBound :: SizeInBytes))
(Either TxConfigurationError () -> Either TxConfigurationError ())
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall a b. (a -> b) -> a -> b
$ TxConfigurationError -> Either TxConfigurationError ()
forall a b. a -> Either a b
Left (NumTxIdsToReq -> TxConfigurationError
MaxNumTxIdsToRequestTooLarge NumTxIdsToReq
maxNumTxIdsToRequest)
Bool
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (SizeInBytes
txsSizeInflightPerPeer SizeInBytes -> SizeInBytes -> Bool
forall a. Ord a => a -> a -> Bool
> SizeInBytes
0)
(Either TxConfigurationError () -> Either TxConfigurationError ())
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall a b. (a -> b) -> a -> b
$ TxConfigurationError -> Either TxConfigurationError ()
forall a b. a -> Either a b
Left (SizeInBytes -> TxConfigurationError
TxsSizeInflightPerPeerTooSmall SizeInBytes
txsSizeInflightPerPeer)
Bool
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (SizeInBytes
txsSizePerBatch SizeInBytes -> SizeInBytes -> Bool
forall a. Ord a => a -> a -> Bool
> SizeInBytes
0)
(Either TxConfigurationError () -> Either TxConfigurationError ())
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall a b. (a -> b) -> a -> b
$ TxConfigurationError -> Either TxConfigurationError ()
forall a b. a -> Either a b
Left (SizeInBytes -> TxConfigurationError
TxsSizePerBatchTooSmall SizeInBytes
txsSizePerBatch)
Bool
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ( SizeInBytes -> Integer
forall a. Integral a => a -> Integer
toInteger SizeInBytes
msgReplyTxsFraming
Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ SizeInBytes -> Integer
forall a. Integral a => a -> Integer
toInteger (SizeInBytes -> SizeInBytes -> SizeInBytes
forall a. Ord a => a -> a -> a
max SizeInBytes
txsSizePerBatch SizeInBytes
max_TX_SIZE)
Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ SizeInBytes -> Integer
forall a. Integral a => a -> Integer
toInteger SizeInBytes
const_MAX_TX_SIZE_DISCREPANCY
Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* NumTxIdsToAck -> Integer
forall a. Integral a => a -> Integer
toInteger NumTxIdsToAck
maxNumUnacknowledgedTxIds
Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
<= Word -> Integer
forall a. Integral a => a -> Integer
toInteger Word
stTxsSizeLimit)
(Either TxConfigurationError () -> Either TxConfigurationError ())
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall a b. (a -> b) -> a -> b
$ TxConfigurationError -> Either TxConfigurationError ()
forall a b. a -> Either a b
Left (SizeInBytes -> NumTxIdsToAck -> TxConfigurationError
TxsSizePerBatchTooLarge SizeInBytes
txsSizePerBatch NumTxIdsToAck
maxNumUnacknowledgedTxIds)
Bool
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Int
maxOutstandingTxBatchesPerPeer Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
1)
(Either TxConfigurationError () -> Either TxConfigurationError ())
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall a b. (a -> b) -> a -> b
$ TxConfigurationError -> Either TxConfigurationError ()
forall a b. a -> Either a b
Left (Int -> TxConfigurationError
MaxOutstandingTxBatchesPerPeerTooSmall Int
maxOutstandingTxBatchesPerPeer)
Bool
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Int
txInflightMultiplicity Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
1)
(Either TxConfigurationError () -> Either TxConfigurationError ())
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall a b. (a -> b) -> a -> b
$ TxConfigurationError -> Either TxConfigurationError ()
forall a b. a -> Either a b
Left (Int -> TxConfigurationError
TxInflightMultiplicityTooSmall Int
txInflightMultiplicity)
Bool
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (DiffTime
bufferedTxsMinLifetime DiffTime -> DiffTime -> Bool
forall a. Ord a => a -> a -> Bool
>= DiffTime
0)
(Either TxConfigurationError () -> Either TxConfigurationError ())
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall a b. (a -> b) -> a -> b
$ TxConfigurationError -> Either TxConfigurationError ()
forall a b. a -> Either a b
Left (DiffTime -> TxConfigurationError
BufferedTxsMinLifetimeTooSmall DiffTime
bufferedTxsMinLifetime)
Bool
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Double
scoreRate Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
>= Double
0)
(Either TxConfigurationError () -> Either TxConfigurationError ())
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall a b. (a -> b) -> a -> b
$ TxConfigurationError -> Either TxConfigurationError ()
forall a b. a -> Either a b
Left (Double -> TxConfigurationError
ScoreRateTooSmall Double
scoreRate)
Bool
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Double
scoreMax Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
>= Double
0)
(Either TxConfigurationError () -> Either TxConfigurationError ())
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall a b. (a -> b) -> a -> b
$ TxConfigurationError -> Either TxConfigurationError ()
forall a b. a -> Either a b
Left (Double -> TxConfigurationError
ScoreMaxTooSmall Double
scoreMax)
Bool
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Double
scoreAcceptDecrement Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
>= Double
0)
(Either TxConfigurationError () -> Either TxConfigurationError ())
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall a b. (a -> b) -> a -> b
$ TxConfigurationError -> Either TxConfigurationError ()
forall a b. a -> Either a b
Left (Double -> TxConfigurationError
ScoreAcceptDecrementTooSmall Double
scoreAcceptDecrement)
Bool
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (DiffTime
interTxSpace DiffTime -> DiffTime -> Bool
forall a. Ord a => a -> a -> Bool
>= DiffTime
0)
(Either TxConfigurationError () -> Either TxConfigurationError ())
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall a b. (a -> b) -> a -> b
$ TxConfigurationError -> Either TxConfigurationError ()
forall a b. a -> Either a b
Left (DiffTime -> TxConfigurationError
InterTxSpaceTooSmall DiffTime
interTxSpace)
Bool
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (DiffTime
inflightTimeout DiffTime -> DiffTime -> Bool
forall a. Ord a => a -> a -> Bool
>= DiffTime
interTxSpace)
(Either TxConfigurationError () -> Either TxConfigurationError ())
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall a b. (a -> b) -> a -> b
$ TxConfigurationError -> Either TxConfigurationError ()
forall a b. a -> Either a b
Left (DiffTime -> DiffTime -> TxConfigurationError
InflightTimeoutTooSmall DiffTime
inflightTimeout DiffTime
interTxSpace)
Bool
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (DiffTime
maxPeerClaimDelay DiffTime -> DiffTime -> Bool
forall a. Ord a => a -> a -> Bool
>= DiffTime
0)
(Either TxConfigurationError () -> Either TxConfigurationError ())
-> Either TxConfigurationError () -> Either TxConfigurationError ()
forall a b. (a -> b) -> a -> b
$ TxConfigurationError -> Either TxConfigurationError ()
forall a b. a -> Either a b
Left (DiffTime -> TxConfigurationError
MaxPeerClaimDelayTooSmall DiffTime
maxPeerClaimDelay)