Skip to content

Commit

Permalink
Merge pull request #1038 from input-output-hk/KtorZ/reduce-exponentia…
Browse files Browse the repository at this point in the history
…l-backoff-network

reduce network exponential backoff maximum cap to 10s
  • Loading branch information
Matthias Benkort authored Nov 14, 2019
2 parents 02789c9 + 1c92b13 commit b792178
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions lib/core/src/Cardano/Wallet/Network.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ import Control.Monad.IO.Class
import Control.Monad.Trans.Except
( ExceptT, runExceptT )
import Control.Retry
( RetryPolicyM
, exponentialBackoff
, limitRetriesByCumulativeDelay
, retrying
)
( RetryPolicyM, constantDelay, limitRetriesByCumulativeDelay, retrying )
import Data.List.NonEmpty
( NonEmpty (..) )
import Data.Map
Expand Down Expand Up @@ -207,7 +203,7 @@ waitForNetwork getStatus policy = do
-- for no longer than a minute.
defaultRetryPolicy :: Monad m => RetryPolicyM m
defaultRetryPolicy =
limitRetriesByCumulativeDelay (3600 * second) (exponentialBackoff 10000)
limitRetriesByCumulativeDelay (3600 * second) (constantDelay second)
where
second = 1000*1000

Expand Down Expand Up @@ -279,11 +275,11 @@ follow nl tr cps yield rollback header =
sleep 0 (initCursor nl cps)
where
delay0 :: Int
delay0 = 1000*1000 -- 1 second
delay0 = 500*1000 -- 500ms

retryDelay :: Int -> Int
retryDelay 0 = delay0
retryDelay delay = min (2*delay) (60 * delay0)
retryDelay delay = min (2*delay) (10 * delay0)

-- | Wait a short delay before querying for blocks again. We also take this
-- opportunity to refresh the chain tip as it has probably increased in
Expand Down
2 changes: 1 addition & 1 deletion lib/core/test/unit/Cardano/Wallet/NetworkSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ followSpec =
(follow mockNetworkLayer tr [] advance rollback getHeader)
errors <- mapMaybe (unMsg . loContent) <$> readTVarIO tvar
case length errors of
x | x == 4 -> return ()
x | x == 5 -> return ()
| otherwise -> expectationFailure
$ "we expected 4 errors to be logged, not " ++ show x
where
Expand Down

0 comments on commit b792178

Please sign in to comment.