Skip to content

Commit

Permalink
p2p-governor: fixed setCurrentTime
Browse files Browse the repository at this point in the history
When checking if we need to udate the state, we need to take
'nextConnectTimes' into account.
  • Loading branch information
coot committed Jan 29, 2021
1 parent 455238b commit 6930e05
Showing 1 changed file with 6 additions and 2 deletions.
Expand Up @@ -36,6 +36,7 @@ import qualified Data.Set as Set
import Data.Set (Set)
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import Data.Semigroup (Min (..))
import qualified Data.OrdPSQ as PSQ
import Data.OrdPSQ (OrdPSQ)
--import System.Random (RandomGen(..))
Expand Down Expand Up @@ -240,11 +241,14 @@ setCurrentTime :: Ord peeraddr
=> Time
-> KnownPeers peeraddr
-> KnownPeers peeraddr
setCurrentTime now knownPeers@KnownPeers { nextGossipTimes }
setCurrentTime now knownPeers@KnownPeers { nextGossipTimes, nextConnectTimes }
-- Efficient check for the common case of there being nothing to do:
| Just (_,t,_,_) <- PSQ.minView nextGossipTimes
| Just (Min t) <- (f <$> PSQ.minView nextGossipTimes)
<> (f <$> PSQ.minView nextConnectTimes)
, t > now
= knownPeers
where
f (_,t,_,_) = Min t

setCurrentTime now knownPeers@KnownPeers {
availableForGossip,
Expand Down

0 comments on commit 6930e05

Please sign in to comment.