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 May 7, 2024
1 parent e909573 commit e45e4e3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module Ouroboros.Network.PeerSelection.Governor
, PublicPeerSelectionState (..)
, makePublicPeerSelectionStateVar
, PeerSelectionCounters (..)
, peerSelectionStateToCounters
, emptyPeerSelectionCounters
, nullPeerSelectionTargets
, emptyPeerSelectionState
Expand Down Expand Up @@ -559,7 +560,7 @@ peerSelectionGovernorLoop tracer
now <- getMonotonicTime
let Decision { decisionTrace, decisionJobs, decisionState } =
timedDecision now
!newCounters = peerStateToCounters decisionState
!newCounters = peerSelectionStateToCounters decisionState

atomically $ do
-- Update counters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,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 @@ -762,16 +762,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 e45e4e3

Please sign in to comment.