6464
6565package com .radixdlt .consensus .liveness ;
6666
67+ import com .google .common .math .LinearTransformation ;
6768import com .google .common .primitives .Doubles ;
6869import com .google .common .util .concurrent .RateLimiter ;
6970import com .google .inject .Inject ;
@@ -110,12 +111,9 @@ public long calculateTimeoutMs(long timeoutOccurrences, double vertexStoreUtiliz
110111 // from [threshold, 1] to [1, maxExponent] to get the exponent
111112 // for the vertex store utilization factor.
112113 final var exponent =
113- lerp (
114- config .vertexStoreUtilizationFactorThreshold (),
115- 1.0 ,
116- 0.0 ,
117- config .vertexStoreUtilizationFactorMaxExponent (),
118- vertexStoreUtilizationRatioClamped );
114+ LinearTransformation .mapping (config .vertexStoreUtilizationFactorThreshold (), 0.0 )
115+ .and (1.0 , config .vertexStoreUtilizationFactorMaxExponent ())
116+ .transform (vertexStoreUtilizationRatioClamped );
119117 vertexStoreUtilizationFactor = Math .pow (config .vertexStoreUtilizationFactorRate (), exponent );
120118 }
121119
@@ -140,16 +138,6 @@ public long calculateTimeoutMs(long timeoutOccurrences, double vertexStoreUtiliz
140138 return res ;
141139 }
142140
143- // Computes a linear interpolation (or extrapolation).
144- // The input value `z` is interpolated from the source range [x, y]
145- // to the target range [p, q].
146- // E.g. if [x, y] = [10, 20], z = 15 and [p, q] = [0, 1], returns 0.5.
147- // If z is outside [x, y] then it's extrapolated (linearly) and can produce
148- // a value outside [p, q]. This should be handled by the caller.
149- private static double lerp (double x , double y , double p , double q , double z ) {
150- return p + (q - p ) * (z - x ) / (y - x );
151- }
152-
153141 @ Override
154142 public long additionalRoundTimeIfProposalReceivedMs () {
155143 return config .additionalRoundTimeIfProposalReceivedMs ();
0 commit comments