Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 729604b

Browse files
committed
Update client for the new methods
1 parent 8047e26 commit 729604b

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

node/src/Cardano/Node/Client.hs

+25-10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ module Cardano.Node.Client
1010
-- * HTTP instance
1111
, NodeHttpClient
1212
, mkHttpClient
13+
-- * Deprecated
14+
, applyUpdate
15+
, postponeUpdate
1316
) where
1417

1518
import Universum
@@ -22,9 +25,10 @@ import Servant.Client (BaseUrl (..), ClientEnv (..), ClientM,
2225
GenResponse (..), ServantError, client, runClientM)
2326
import qualified Servant.Client as Servant
2427

28+
import qualified Pos.Chain.Update as Core
2529
import Cardano.Node.API (nodeV1Api)
2630
import Pos.Chain.Txp (Utxo)
27-
import Pos.Node.API (ForceNtpCheck, NodeInfo, NodeSettings)
31+
import Pos.Node.API (ForceNtpCheck, NodeInfo, NodeSettings, V1)
2832
import Pos.Util.Jsend (ResponseStatus (..))
2933
import Pos.Util.Servant (APIResponse (..))
3034
import Pos.Web.Types (CConfirmedProposalState)
@@ -47,14 +51,25 @@ data NodeClient m
4751
:: ForceNtpCheck
4852
-> m NodeInfo
4953

50-
, applyUpdate
54+
, restartNode
5155
:: m ()
5256

53-
, postponeUpdate
54-
:: m ()
57+
, getNextUpdate
58+
:: m (V1 Core.SoftwareVersion)
5559
} deriving (Generic)
5660

5761

62+
-- | A backwards compatibility wrapper for 'restartNode'.
63+
applyUpdate :: NodeClient m -> m ()
64+
applyUpdate = restartNode
65+
{-# DEPRECATED applyUpdate "Use 'restartNode' instead." #-}
66+
67+
-- | 'postponeUpdate' was removed from the API. This is a backwards
68+
-- compatibility wrapper that is deprecated.
69+
postponeUpdate :: Applicative m => NodeClient n -> m ()
70+
postponeUpdate _ = pure ()
71+
{-# DEPRECATED postponeUpdate "This endpoint was turned into a noop." #-}
72+
5873
data ClientError a
5974
= KnownError a
6075
| ErrFromServant Servant.ServantError
@@ -92,10 +107,10 @@ mkHttpClient baseUrl manager = NodeClient
92107
fmap wrData $ run getNodeSettingsR
93108
, getNodeInfo =
94109
fmap wrData . run . getNodeInfoR
95-
, applyUpdate =
96-
void $ run applyUpdateR
97-
, postponeUpdate =
98-
void $ run postponeUpdateR
110+
, getNextUpdate =
111+
wrData <$> run getNextUpdateR
112+
, restartNode =
113+
void $ run restartNodeR
99114
}
100115
where
101116
run :: forall a. ClientM a -> ExceptT (ClientError ()) IO a
@@ -107,8 +122,8 @@ mkHttpClient baseUrl manager = NodeClient
107122

108123
( getNodeSettingsR
109124
:<|> getNodeInfoR
110-
:<|> applyUpdateR
111-
:<|> postponeUpdateR
125+
:<|> getNextUpdateR
126+
:<|> restartNodeR
112127
):<|>( getUtxoR
113128
:<|> getConfirmedProposalsR
114129
) = client nodeV1Api

0 commit comments

Comments
 (0)