@@ -25,7 +25,8 @@ import Ntp.Client (NtpConfiguration, NtpStatus (..),
25
25
import Ntp.Packet (NtpOffset )
26
26
import Pos.Chain.Block (LastKnownHeader , LastKnownHeaderTag )
27
27
import Pos.Chain.Ssc (SscContext )
28
- import Pos.Chain.Update (SoftwareVersion , UpdateConfiguration ,
28
+ import Pos.Chain.Update (ConfirmedProposalState (.. ), SoftwareVersion ,
29
+ UpdateConfiguration , UpdateProposal (.. ),
29
30
curSoftwareVersion )
30
31
import Pos.Client.CLI.NodeOptions (NodeApiArgs (.. ))
31
32
import Pos.Context (HasPrimaryKey (.. ), HasSscContext (.. ),
@@ -39,6 +40,7 @@ import Pos.DB.GState.Lock (Priority (..), StateLock,
39
40
withStateLockNoMetrics )
40
41
import qualified Pos.DB.Rocks as DB
41
42
import Pos.DB.Txp.MemState (GenericTxpLocalData , TxpHolderTag )
43
+ import Pos.DB.Update (UpdateContext (.. ))
42
44
import Pos.Infra.Diffusion.Subscription.Status (ssMap )
43
45
import Pos.Infra.Diffusion.Types (Diffusion (.. ))
44
46
import Pos.Infra.InjectFail (FInject (.. ), testLogFInject )
@@ -163,6 +165,7 @@ launchNodeServer
163
165
updateConfiguration
164
166
compileTimeInfo
165
167
shutdownCtx
168
+ (ncUpdateContext nodeCtx)
166
169
:<|> legacyApi
167
170
168
171
concurrently_
@@ -213,13 +216,13 @@ handlers
213
216
-> UpdateConfiguration
214
217
-> CompileTimeInfo
215
218
-> ShutdownContext
219
+ -> UpdateContext
216
220
-> ServerT Node. API Handler
217
- handlers d t s n l ts sv uc ci sc =
221
+ handlers d t s n l ts sv uc ci sc uCtx =
218
222
getNodeSettings ci uc ts sv
219
223
:<|> getNodeInfo d t s n l
220
- :<|> applyUpdate sc
221
- :<|> postponeUpdate
222
- :<|> getNextUpdate
224
+ :<|> getNextUpdate uCtx
225
+ :<|> restartNode sc
223
226
224
227
--------------------------------------------------------------------------------
225
228
-- Node Settings
@@ -263,33 +266,23 @@ instance Core.HasSlottingVar SettingsCtx where
263
266
-- Updates
264
267
--------------------------------------------------------------------------------
265
268
266
- applyUpdate :: ShutdownContext -> Handler NoContent
267
- applyUpdate shutdownCtx = liftIO $ do
269
+ -- | Handler
270
+ restartNode :: ShutdownContext -> Handler NoContent
271
+ restartNode shutdownCtx = liftIO $ do
268
272
doFail <- testLogFInject (_shdnFInjects shutdownCtx) FInjApplyUpdateNoExit
269
273
unless doFail (runReaderT triggerShutdown shutdownCtx)
270
274
pure NoContent
271
275
272
- -- | In the old implementation, we would delete the new update from the
273
- -- acid-stae database. We no longer persist this information, so postponing an
274
- -- update is simply a noop.
275
- --
276
- -- TODO: verify this is a real thought and not, in fact, bad
277
- postponeUpdate :: Handler NoContent
278
- postponeUpdate = do
279
- pure NoContent
280
-
281
276
-- | This endpoint does a 404 unless there is an update available. If an update
282
277
-- is available, it returns the 'SoftwareVersion' for that update.
283
- getNextUpdate :: Handler (APIResponse (V1 SoftwareVersion ))
284
- getNextUpdate = do
285
- mupdate <- readUpdate
286
- single <$> case mupdate of
287
- Just update ->
288
- pure update
278
+ getNextUpdate :: UpdateContext -> Handler (APIResponse (V1 SoftwareVersion ))
279
+ getNextUpdate uc = do
280
+ mproposalState <- tryReadMVar (ucDownloadedUpdate uc)
281
+ single <$> case mproposalState of
282
+ Just proposalState ->
283
+ pure ( V1 (upSoftwareVersion (cpsUpdateProposal proposalState)))
289
284
Nothing ->
290
285
throwError err404
291
- where
292
- readUpdate = undefined
293
286
294
287
--------------------------------------------------------------------------------
295
288
-- Node Info
0 commit comments