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

Commit

Permalink
Update client for the new methods
Browse files Browse the repository at this point in the history
  • Loading branch information
parsonsmatt committed Dec 14, 2018
1 parent 8047e26 commit a68df8b
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions node/src/Cardano/Node/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ module Cardano.Node.Client
-- * HTTP instance
, NodeHttpClient
, mkHttpClient
-- * Deprecated
, applyUpdate
, postponeUpdate
) where

import Universum
Expand All @@ -24,7 +27,8 @@ import qualified Servant.Client as Servant

import Cardano.Node.API (nodeV1Api)
import Pos.Chain.Txp (Utxo)
import Pos.Node.API (ForceNtpCheck, NodeInfo, NodeSettings)
import qualified Pos.Chain.Update as Core
import Pos.Node.API (ForceNtpCheck, NodeInfo, NodeSettings, V1)
import Pos.Util.Jsend (ResponseStatus (..))
import Pos.Util.Servant (APIResponse (..))
import Pos.Web.Types (CConfirmedProposalState)
Expand All @@ -47,14 +51,25 @@ data NodeClient m
:: ForceNtpCheck
-> m NodeInfo

, applyUpdate
, restartNode
:: m ()

, postponeUpdate
:: m ()
, getNextUpdate
:: m (V1 Core.SoftwareVersion)
} deriving (Generic)


-- | A backwards compatibility wrapper for 'restartNode'.
applyUpdate :: NodeClient m -> m ()
applyUpdate = restartNode
{-# DEPRECATED applyUpdate "Use 'restartNode' instead." #-}

-- | 'postponeUpdate' was removed from the API. This is a backwards
-- compatibility wrapper that is deprecated.
postponeUpdate :: Applicative m => NodeClient n -> m ()
postponeUpdate _ = pure ()
{-# DEPRECATED postponeUpdate "This endpoint was turned into a noop." #-}

data ClientError a
= KnownError a
| ErrFromServant Servant.ServantError
Expand Down Expand Up @@ -92,10 +107,10 @@ mkHttpClient baseUrl manager = NodeClient
fmap wrData $ run getNodeSettingsR
, getNodeInfo =
fmap wrData . run . getNodeInfoR
, applyUpdate =
void $ run applyUpdateR
, postponeUpdate =
void $ run postponeUpdateR
, getNextUpdate =
wrData <$> run getNextUpdateR
, restartNode =
void $ run restartNodeR
}
where
run :: forall a. ClientM a -> ExceptT (ClientError ()) IO a
Expand All @@ -107,8 +122,8 @@ mkHttpClient baseUrl manager = NodeClient

( getNodeSettingsR
:<|> getNodeInfoR
:<|> applyUpdateR
:<|> postponeUpdateR
:<|> getNextUpdateR
:<|> restartNodeR
):<|>( getUtxoR
:<|> getConfirmedProposalsR
) = client nodeV1Api

0 comments on commit a68df8b

Please sign in to comment.