Skip to content

Commit

Permalink
Merge pull request input-output-hk#1590 from input-output-hk/flyingle…
Browse files Browse the repository at this point in the history
…afe/csm456-rc

[CSM-458] Endpoint for postponing the update (version for RC)
  • Loading branch information
fersel authored Sep 20, 2017
2 parents 14dcad0 + 1bd83ee commit 8e3ebbf
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 2 deletions.
5 changes: 4 additions & 1 deletion daedalus/src/Daedalus/BackendApi.purs
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,11 @@ getHistory tls walletId accountId addr skip limit =
nextUpdate :: forall eff. TLSOptions -> Aff (http :: HTTP, exception :: EXCEPTION | eff) CUpdateInfo
nextUpdate tls = getR tls $ noQueryParam ["update"]

postponeUpdate :: forall eff. TLSOptions -> Aff (http :: HTTP, exception :: EXCEPTION | eff) Unit
postponeUpdate tls = postR tls $ noQueryParam ["update", "postpone"]

applyUpdate :: forall eff. TLSOptions -> Aff (http :: HTTP, exception :: EXCEPTION | eff) Unit
applyUpdate tls = postR tls $ noQueryParam ["update"]
applyUpdate tls = postR tls $ noQueryParam ["update", "apply"]

--------------------------------------------------------------------------------
-- Redemptions -----------------------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions daedalus/src/Daedalus/ClientApi.purs
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,15 @@ getAddressHistory = mkEffFn5 \tls acId address skip limit -> fromAff <<< map enc
nextUpdate :: forall eff. EffFn1 (http :: HTTP, exception :: EXCEPTION | eff) TLSOptions (Promise Json)
nextUpdate = mkEffFn1 $ fromAff <<< map encodeJson <<< B.nextUpdate

-- Example in nodejs:
-- | ```js
-- | > api.postponeUpdate().then(console.log).catch(console.log)
-- | Promise { <pending> }
-- | > {}
-- | ```
postponeUpdate :: forall eff. EffFn1 (http :: HTTP, exception :: EXCEPTION | eff) TLSOptions (Promise Unit)
postponeUpdate = mkEffFn1 $ fromAff <<< B.postponeUpdate

-- Example in nodejs:
-- | ```js
-- | > api.applyUpdate().then(console.log).catch(console.log)
Expand Down
2 changes: 2 additions & 0 deletions pkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4445,6 +4445,8 @@ self: {
pname = "memory";
version = "0.14.6";
sha256 = "0q61zxdlgcw7wg244hb3c11qm5agrmnmln0h61sz2mj72xqc1pn7";
revision = "1";
editedCabalFile = "0pyzdy5ca1cbkjzy1scnz6mr9251ap4w8a5phzxp91wkxpc45538";
libraryHaskellDepends = [
base
bytestring
Expand Down
9 changes: 9 additions & 0 deletions wallet/src/Pos/Wallet/Web/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module Pos.Wallet.Web.Api
, GetHistory

, NextUpdate
, PostponeUpdate
, ApplyUpdate

, RedeemADA
Expand Down Expand Up @@ -274,8 +275,14 @@ type NextUpdate =
"update"
:> WRes Get CUpdateInfo

type PostponeUpdate =
"update"
:> "postpone"
:> WRes Post ()

type ApplyUpdate =
"update"
:> "apply"
:> WRes Post ()

-------------------------------------------------------------------------
Expand Down Expand Up @@ -420,6 +427,8 @@ type WalletApi = ApiPrefix :> (
-- Updates
-------------------------------------------------------------------------
NextUpdate
:<|>
PostponeUpdate
:<|>
ApplyUpdate
:<|>
Expand Down
8 changes: 7 additions & 1 deletion wallet/src/Pos/Wallet/Web/Methods/Misc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module Pos.Wallet.Web.Methods.Misc
, isValidAddress

, nextUpdate
, postponeUpdate
, applyUpdate

, syncProgress
Expand All @@ -25,7 +26,7 @@ import Pos.Util (maybeThrow)
import Pos.Wallet.KeyStorage (deleteSecretKey, getSecretKeys)
import Pos.Wallet.WalletMode (applyLastUpdate, connectedPeers,
localChainDifficulty, networkChainDifficulty)
import Pos.Wallet.Web.ClientTypes (CProfile, CProfile (..), CUpdateInfo (..),
import Pos.Wallet.Web.ClientTypes (CProfile (..), CUpdateInfo (..),
SyncProgress (..))
import Pos.Wallet.Web.Error (WalletError (..))
import Pos.Wallet.Web.Mode (MonadWalletWebMode)
Expand Down Expand Up @@ -61,6 +62,11 @@ nextUpdate :: MonadWalletWebMode m => m CUpdateInfo
nextUpdate = getNextUpdate >>=
maybeThrow (RequestError "No updates available")

-- | Postpone next update after restart
postponeUpdate :: MonadWalletWebMode m => m ()
postponeUpdate = removeNextUpdate

-- | Delete next update info and restart immediately
applyUpdate :: MonadWalletWebMode m => m ()
applyUpdate = removeNextUpdate >> applyLastUpdate

Expand Down
2 changes: 2 additions & 0 deletions wallet/src/Pos/Wallet/Web/Server/Handlers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ servantHandlers sendActions =
:<|>

M.nextUpdate
:<|>
M.postponeUpdate
:<|>
M.applyUpdate
:<|>
Expand Down
4 changes: 4 additions & 0 deletions wallet/src/Pos/Wallet/Web/Swagger/Description.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ instance HasCustomSwagger NextUpdate where
swaggerModifier = modifyDescription
"Get information about the next update."

instance HasCustomSwagger PostponeUpdate where
swaggerModifier = modifyDescription
"Postpone last update."

instance HasCustomSwagger ApplyUpdate where
swaggerModifier = modifyDescription
"Apply last update."
Expand Down

0 comments on commit 8e3ebbf

Please sign in to comment.