Skip to content

Commit

Permalink
Merge #2464
Browse files Browse the repository at this point in the history
2464: Remove unused ErrListPools r=Anviking a=Anviking

# Issue Number

ADP-647


# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] Remove `ErrStakeDistributionQuery` which is unused since #2449
- [x] Remove `ErrListPoolsPastHorizonException` which is also unused (we use `unsafeExtendSafeZone`, so it will never fail)
- [x] Remove the `ErrListPools` type entirely 


# Comments

<!-- Additional comments or screenshots to attach if any -->

<!--
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
 ✓ Finally, in the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages.
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
  • Loading branch information
iohk-bors[bot] and Anviking committed Jan 26, 2021
2 parents df25b2c + 2219bd1 commit e002a9d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 47 deletions.
9 changes: 0 additions & 9 deletions lib/core/src/Cardano/Wallet.hs
Expand Up @@ -172,9 +172,6 @@ module Cardano.Wallet

-- * Logging
, WalletLog (..)

-- * Stake pool listing
, ErrListPools (..)
) where

import Prelude hiding
Expand Down Expand Up @@ -204,7 +201,6 @@ import Cardano.Wallet.Network
( ErrGetAccountBalance (..)
, ErrNetworkUnavailable (..)
, ErrPostTx (..)
, ErrStakeDistribution (..)
, FollowAction (..)
, FollowExit (..)
, FollowLog (..)
Expand Down Expand Up @@ -2560,11 +2556,6 @@ data ErrWithdrawalNotWorth
= ErrWithdrawalNotWorth
deriving (Generic, Eq, Show)

-- | Errors that can occur when trying to list stake pool.
data ErrListPools
= ErrListPoolsQueryFailed ErrStakeDistribution
| ErrListPoolsPastHorizonException PastHorizonException
deriving (Show)
{-------------------------------------------------------------------------------
Utils
-------------------------------------------------------------------------------}
Expand Down
21 changes: 1 addition & 20 deletions lib/core/src/Cardano/Wallet/Api/Server.hs
Expand Up @@ -118,7 +118,6 @@ import Cardano.Wallet
, ErrImportRandomAddress (..)
, ErrInvalidDerivationIndex (..)
, ErrJoinStakePool (..)
, ErrListPools (..)
, ErrListTransactions (..)
, ErrListUTxOStatistics (..)
, ErrMkTx (..)
Expand Down Expand Up @@ -235,11 +234,7 @@ import Cardano.Wallet.Api.Types
import Cardano.Wallet.DB
( DBFactory (..) )
import Cardano.Wallet.Network
( ErrNetworkUnavailable (..)
, ErrStakeDistribution (..)
, NetworkLayer
, timeInterpreter
)
( ErrNetworkUnavailable (..), NetworkLayer, timeInterpreter )
import Cardano.Wallet.Primitive.AddressDerivation
( DelegationAddress (..)
, Depth (..)
Expand Down Expand Up @@ -2845,20 +2840,6 @@ instance LiftHandler ErrWithdrawalNotWorth where
, "request."
]

instance LiftHandler ErrListPools where
handler = \case
ErrListPoolsQueryFailed e -> handler e
ErrListPoolsPastHorizonException e -> handler e

instance LiftHandler ErrStakeDistribution where
handler = \case
ErrStakeDistributionQuery _e ->
apiError err503 NetworkQueryFailed $ mconcat
[ "Unable to query the ledger at the moment. "
, "This error has been logged. "
, "Trying again in a bit might work."
]

instance LiftHandler ErrSignMetadataWith where
handler = \case
ErrSignMetadataWithRootKey e -> handler e
Expand Down
9 changes: 1 addition & 8 deletions lib/core/src/Cardano/Wallet/Network.hs
Expand Up @@ -26,7 +26,6 @@ module Cardano.Wallet.Network
, ErrGetTxParameters (..)
, ErrPostTx (..)
, ErrGetAccountBalance (..)
, ErrStakeDistribution (..)

-- * Logging
, FollowLog (..)
Expand Down Expand Up @@ -148,7 +147,7 @@ data NetworkLayer m block = NetworkLayer

, stakeDistribution
:: Coin -- Stake to consider for rewards
-> ExceptT ErrStakeDistribution m StakePoolsSummary
-> m StakePoolsSummary

, getAccountBalance
:: RewardAccount
Expand Down Expand Up @@ -201,12 +200,6 @@ data ErrGetAccountBalance
| ErrGetAccountBalanceAccountNotFound RewardAccount
deriving (Generic, Eq, Show)

-- | Error while querying stake distribution from ledger.
newtype ErrStakeDistribution
= ErrStakeDistributionQuery Text
-- ^ Query failed.
deriving (Generic, Show, Eq)

{-------------------------------------------------------------------------------
Initialization
-------------------------------------------------------------------------------}
Expand Down
2 changes: 1 addition & 1 deletion lib/shelley/src/Cardano/Wallet/Shelley/Api/Server.hs
Expand Up @@ -286,7 +286,7 @@ server byron icarus shelley spl ntp =
listStakePools_ = \case
Just (ApiT stake) -> do
currentEpoch <- getCurrentEpoch shelley
liftHandler $ listStakePools spl currentEpoch stake
liftIO $ listStakePools spl currentEpoch stake
Nothing -> Handler $ throwE $ apiError err400 QueryParamMissing $
mconcat
[ "The stake intended to delegate must be provided as a query "
Expand Down
4 changes: 2 additions & 2 deletions lib/shelley/src/Cardano/Wallet/Shelley/Network.hs
Expand Up @@ -341,7 +341,7 @@ withNetworkLayerBase tr np conn (versionData, _) action = do
era <- liftIO readCurrentNodeEra
_postTx localTxSubmissionQ era sealed
, stakeDistribution =
liftIO . _stakeDistribution queryRewardQ
_stakeDistribution queryRewardQ
, getAccountBalance =
_getAccountBalance rewardsObserver
, timeInterpreter =
Expand Down Expand Up @@ -486,7 +486,7 @@ withNetworkLayerBase tr np conn (versionData, _) action = do
queue `send` (SomeLSQ qry )

-- The result will be Nothing if query occurs during the byron era
liftIO $ traceWith tr $ MsgFetchStakePoolsData mres
traceWith tr $ MsgFetchStakePoolsData mres
case mres of
Just res@W.StakePoolsSummary{rewards,stake} -> do
liftIO $ traceWith tr $ MsgFetchStakePoolsDataSummary
Expand Down
11 changes: 4 additions & 7 deletions lib/shelley/src/Cardano/Wallet/Shelley/Pools.hs
Expand Up @@ -52,8 +52,6 @@ import Cardano.Pool.Metadata
, registryUrlBuilder
, toHealthCheckSMASH
)
import Cardano.Wallet
( ErrListPools (..) )
import Cardano.Wallet.Api.Types
( ApiT (..), HealthCheckSMASH (..), toApiEpochInfo )
import Cardano.Wallet.Byron.Compatibility
Expand Down Expand Up @@ -119,7 +117,7 @@ import Control.Monad
import Control.Monad.IO.Class
( liftIO )
import Control.Monad.Trans.Except
( ExceptT (..), mapExceptT, runExceptT )
( ExceptT (..), runExceptT )
import Control.Monad.Trans.State
( State, evalState, state )
import Control.Retry
Expand Down Expand Up @@ -204,7 +202,7 @@ data StakePoolLayer = StakePoolLayer
:: EpochNo
-- Exclude all pools that retired in or before this epoch.
-> Coin
-> ExceptT ErrListPools IO [Api.ApiStakePool]
-> IO [Api.ApiStakePool]

, forceMetadataGC :: IO ()

Expand Down Expand Up @@ -268,10 +266,9 @@ newStakePoolLayer gcStatus nl db@DBLayer {..} restartSyncThread = do
:: EpochNo
-- Exclude all pools that retired in or before this epoch.
-> Coin
-> ExceptT ErrListPools IO [Api.ApiStakePool]
-> IO [Api.ApiStakePool]
_listPools currentEpoch userStake = do
rawLsqData <- mapExceptT (fmap (first ErrListPoolsQueryFailed))
$ stakeDistribution nl userStake
rawLsqData <- liftIO $ stakeDistribution nl userStake
let lsqData = combineLsqData rawLsqData
dbData <- liftIO $ readPoolDbData db currentEpoch
seed <- liftIO $ atomically readSystemSeed
Expand Down

0 comments on commit e002a9d

Please sign in to comment.