Skip to content

Commit

Permalink
peer-selection: renamed peerStateToCounters
Browse files Browse the repository at this point in the history
Also export it from `Governor` module, it is useful in `cardano-node`.
  • Loading branch information
coot committed Apr 16, 2024
1 parent 3e4190a commit f7277cb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
Expand Up @@ -30,6 +30,7 @@ module Ouroboros.Network.PeerSelection.Governor
, PublicPeerSelectionState (..)
, makePublicPeerSelectionStateVar
, PeerSelectionCounters (..)
, peerSelectionStateToCounters
, emptyPeerSelectionCounters
, nullPeerSelectionTargets
, emptyPeerSelectionState
Expand Down Expand Up @@ -557,7 +558,7 @@ peerSelectionGovernorLoop tracer
now <- getMonotonicTime
let Decision { decisionTrace, decisionJobs, decisionState } =
timedDecision now
!newCounters = peerStateToCounters decisionState
!newCounters = peerSelectionStateToCounters decisionState

atomically $ do
-- Update counters
Expand Down
Expand Up @@ -39,7 +39,7 @@ module Ouroboros.Network.PeerSelection.Governor.Types
, Completion (..)
, PeerSelectionCounters (.., PeerSelectionCountersHWC, numberOfColdPeers, numberOfWarmPeers, numberOfHotPeers, numberOfColdBigLedgerPeers, numberOfWarmBigLedgerPeers, numberOfHotBigLedgerPeers, numberOfColdLocalRootPeers, numberOfWarmLocalRootPeers, numberOfHotLocalRootPeers, localRootsHWC)
, emptyPeerSelectionCounters
, peerStateToCounters
, peerSelectionStateToCounters
-- * Peer Sharing Auxiliary data type
, PeerSharingResult (..)
-- * Traces
Expand Down Expand Up @@ -752,16 +752,20 @@ peerSelectionCountersHWC PeerSelectionCounters {..} =
}


peerStateToCounters :: Ord peeraddr => PeerSelectionState peeraddr peerconn -> PeerSelectionCounters
peerStateToCounters PeerSelectionState { knownPeers,
establishedPeers,
activePeers,
publicRootPeers,
localRootPeers,
inProgressPromoteCold,
inProgressPromoteWarm,
inProgressDemoteWarm,
inProgressDemoteHot } =
peerSelectionStateToCounters :: Ord peeraddr => PeerSelectionState peeraddr peerconn -> PeerSelectionCounters
peerSelectionStateToCounters
PeerSelectionState {
knownPeers,
establishedPeers,
activePeers,
publicRootPeers,
localRootPeers,
inProgressPromoteCold,
inProgressPromoteWarm,
inProgressDemoteWarm,
inProgressDemoteHot
}
=
PeerSelectionCounters {
numberOfRootPeers = Set.size rootPeersSet,

Expand Down

0 comments on commit f7277cb

Please sign in to comment.