Skip to content

Commit

Permalink
peer-selection: updateWithState
Browse files Browse the repository at this point in the history
Also pass `PeerSelectionActions`, which eliminates two extra arguments
from `cardanoPeerSelectionGovernorArgs`.
  • Loading branch information
coot committed Feb 11, 2025
1 parent e45f547 commit 1c37cdf
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1270,11 +1270,6 @@ diffusionSimulation
Cardano.cardanoPublicRootPeersAPI
(Cardano.cardanoPeerSelectionGovernorArgs
(Cardano.cardanoExtraArgsToPeerSelectionActions cardanoExtraArgs)
peerSharing
( Cardano.updateOutboundConnectionsState
$ lpExtraAPI
$ Node.iLedgerPeersConsensusInterface
interfaces)
)
Cardano.cardanoPeerSelectionStatetoCounters
(flip Cardano.ExtraPeers Set.empty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4015,8 +4015,6 @@ _governorFindingPublicRoots targetNumberOfRootPeers readDomains readUseBootstrap
genesisPeerTargets = targets,
readUseBootstrapPeers = readUseBootstrapPeers
}
peerSharing
(Cardano.updateOutboundConnectionsState (lpExtraAPI (getLedgerStateCtx actions)))


publicRootPeersProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,6 @@ governorAction mockEnv@GovernorMockEnvironment {
Cardano.genesisPeerTargets = snd initialPeerTargets,
Cardano.readUseBootstrapPeers = readUseBootstrapPeers
}
(peerSharing actions)
(Cardano.updateOutboundConnectionsState (lpExtraAPI (getLedgerStateCtx actions)))


exploreRaces -- explore races within the governor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import Ouroboros.Cardano.Network.PeerSelection.Governor.Monitor qualified as Car
import Ouroboros.Cardano.Network.PeerSelection.Governor.PeerSelectionActions qualified as Cardano
import Ouroboros.Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Cardano
import Ouroboros.Cardano.Network.PublicRootPeers qualified as Cardano
import Ouroboros.Network.PeerSelection.LedgerPeers (LedgerPeersConsensusInterface (lpExtraAPI))
import Ouroboros.Network.PeerSelection.Governor (readAssociationMode)
import Ouroboros.Network.PeerSelection.Governor.Types (AssociationMode (..),
BootstrapPeersCriticalTimeoutError (..), ExtraGuardedDecisions (..),
PeerSelectionInterfaces (..), PeerSelectionGovernorArgs (..),
PeerSelectionSetsWithSizes, PeerSelectionState (..),
PeerSelectionView (..))
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing)
PeerSelectionActions (..), PeerSelectionInterfaces (..),
PeerSelectionGovernorArgs (..), PeerSelectionSetsWithSizes,
PeerSelectionState (..), PeerSelectionView (..))
import Ouroboros.Network.PeerSelection.PublicRootPeers qualified as PublicRootPeers
import Ouroboros.Network.PeerSelection.State.EstablishedPeers qualified as EstablishedPeers
import Ouroboros.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers
Expand Down Expand Up @@ -187,8 +187,6 @@ cardanoPeerSelectionGovernorArgs
, Ord peeraddr
)
=> Cardano.ExtraPeerSelectionActions m
-> PeerSharing
-> (OutboundConnectionsState -> STM m ())
-> PeerSelectionGovernorArgs
Cardano.ExtraState
extraDebugState
Expand All @@ -200,7 +198,7 @@ cardanoPeerSelectionGovernorArgs
peerconn
BootstrapPeersCriticalTimeoutError
m
cardanoPeerSelectionGovernorArgs extraActions peerSharing updateOutboundConnectionsState =
cardanoPeerSelectionGovernorArgs extraActions =
PeerSelectionGovernorArgs {
-- If by any chance the node takes more than 15 minutes to converge to a
-- clean state, we crash the node. This could happen in very rare
Expand All @@ -213,11 +211,15 @@ cardanoPeerSelectionGovernorArgs extraActions peerSharing updateOutboundConnecti
Just t
| blockedAt >= t -> Just BootstrapPeersCriticalTimeoutError
| otherwise -> Nothing
, updateWithState = \PeerSelectionInterfaces { readUseLedgerPeers } psv st -> do
, updateWithState = \PeerSelectionInterfaces { readUseLedgerPeers }
PeerSelectionActions { getLedgerStateCtx,
peerSharing }
psv st -> do
associationMode <- readAssociationMode readUseLedgerPeers
peerSharing
(Cardano.bootstrapPeersFlag (extraState st))
updateOutboundConnectionsState
Cardano.updateOutboundConnectionsState
(lpExtraAPI getLedgerStateCtx)
(outboundConnectionsState associationMode psv st)
, extraDecisions =
ExtraGuardedDecisions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ peerSelectionGovernorLoop tracer
peerSelectionStateToView extraPeersToSet extraStateToExtraCounters st''

-- Custom STM actions
updateWithState interfaces peerSelectionView st''
updateWithState interfaces actions peerSelectionView st''

-- Update counters
counters <- readTVar countersVar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ data PeerSelectionGovernorArgs extraState extraDebugState extraFlags
-> Maybe exception
, updateWithState
:: PeerSelectionInterfaces extraState extraFlags extraPeers extraCounters peeraddr peerconn m
-> PeerSelectionActions extraState extraFlags extraPeers extraAPI extraCounters peeraddr peerconn m
-> PeerSelectionSetsWithSizes extraCounters peeraddr
-> PeerSelectionState extraState extraFlags extraPeers peeraddr peerconn
-> STM m ()
Expand Down

0 comments on commit 1c37cdf

Please sign in to comment.