Skip to content

Commit

Permalink
inbound-governor: RemoteHot → RemoteWarm transition
Browse files Browse the repository at this point in the history
Be careful when overwriting the state.
  • Loading branch information
coot authored and bolt12 committed Sep 23, 2021
1 parent 0b1f356 commit 04fee6f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Expand Up @@ -286,7 +286,11 @@ inboundGovernor trTracer tracer serverControlChannel inboundIdleTimeout

let isHot = mpdMiniProtocolTemp == Hot
state' = ( if isHot
then updateRemoteState tConnId RemoteWarm
then mapRemoteState tConnId
$ \remoteState ->
case remoteState of
RemoteHot -> RemoteWarm
_ -> remoteState
else id
)
. updateMiniProtocol tConnId num completionAction
Expand Down
Expand Up @@ -22,6 +22,7 @@ module Ouroboros.Network.InboundGovernor.State
, updateMiniProtocol
, RemoteState (.., RemoteEstablished)
, updateRemoteState
, mapRemoteState
, MiniProtocolData (..)
) where

Expand Down Expand Up @@ -283,3 +284,18 @@ updateRemoteState connId csRemoteState state =
connId
(igsConnections state)
}

mapRemoteState :: Ord peerAddr
=> ConnectionId peerAddr
-> (RemoteState m -> RemoteState m)
-> InboundGovernorState muxMode peerAddr m a b
-> InboundGovernorState muxMode peerAddr m a b
mapRemoteState connId fn state =
state {
igsConnections =
Map.adjust
(\connState@ConnectionState { csRemoteState } ->
connState { csRemoteState = fn csRemoteState })
connId
(igsConnections state)
}

0 comments on commit 04fee6f

Please sign in to comment.