Skip to content

Commit

Permalink
Refine sorting order
Browse files Browse the repository at this point in the history
First `nonMyopicMemberRewards`, then `desirabilityScore`, then randomness from seed
  • Loading branch information
HeinrichApfelmus committed Jan 13, 2022
1 parent 23d2347 commit b4eeb0f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/shelley/src/Cardano/Wallet/Shelley/Pools.hs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ import Data.Word
( Word64 )
import Fmt
( fixedF, pretty )
import Numeric.Natural
( Natural )
import Ouroboros.Consensus.Cardano.Block
( CardanoBlock, HardForkBlock (..) )
import System.Random
Expand Down Expand Up @@ -295,7 +297,12 @@ newStakePoolLayer gcStatus nl db@DBLayer {..} mkCacheWorker restartSyncThread =
sortByReward
:: RandomGen g => g -> [Api.ApiStakePool] -> [Api.ApiStakePool]
sortByReward seed = sortRandomOn seed (Down . rewards)
where rewards = view (#metrics . #nonMyopicMemberRewards)
where
rewards :: Api.ApiStakePool -> (Quantity "lovelace" Natural, Double)
rewards pool =
( view (#metrics . #nonMyopicMemberRewards) pool
, view (#metrics . #desirabilityScore) pool
)

_forceMetadataGC :: IO ()
_forceMetadataGC = do
Expand Down

0 comments on commit b4eeb0f

Please sign in to comment.