@@ -9,7 +9,7 @@ module Cardano.Wallet.Server.Plugins
9
9
, docServer
10
10
, monitoringServer
11
11
, acidStateSnapshots
12
- , updateNotifier
12
+ , updateWatcher
13
13
) where
14
14
15
15
import Universum
@@ -30,14 +30,14 @@ import Cardano.Wallet.Server.CLI (NewWalletBackendParams (..),
30
30
isDebugMode , walletAcidInterval )
31
31
import Cardano.Wallet.WalletLayer (ActiveWalletLayer ,
32
32
PassiveWalletLayer )
33
+ import Pos.Chain.Update (cpsSoftwareVersion )
33
34
import Pos.Crypto (ProtocolMagic )
34
35
import Pos.Infra.Diffusion.Types (Diffusion (.. ))
35
36
import Pos.Infra.Shutdown (HasShutdownContext (shutdownContext ),
36
37
ShutdownContext )
37
38
import Pos.Launcher.Configuration (HasConfigurations )
38
39
import Pos.Util.CompileInfo (HasCompileInfo )
39
- import Pos.Util.Wlog (logError , logInfo , modifyLoggerName ,
40
- usingLoggerName )
40
+ import Pos.Util.Wlog (logInfo , modifyLoggerName , usingLoggerName )
41
41
import Pos.Web (serveDocImpl , serveImpl )
42
42
import qualified Pos.Web.Server
43
43
@@ -46,6 +46,7 @@ import qualified Cardano.Wallet.Kernel.Mode as Kernel
46
46
import qualified Cardano.Wallet.Server as Server
47
47
import Cardano.Wallet.Server.Plugins.AcidState
48
48
(createAndArchiveCheckpoints )
49
+ import qualified Cardano.Wallet.WalletLayer as WalletLayer
49
50
import qualified Cardano.Wallet.WalletLayer.Kernel as WalletLayer.Kernel
50
51
import qualified Data.ByteString.Char8 as BS8
51
52
import qualified Servant
@@ -158,8 +159,12 @@ acidStateSnapshots dbRef params dbMode = pure $ \_diffusion -> do
158
159
(walletAcidInterval opts)
159
160
dbMode
160
161
161
- -- | A @Plugin@ to notify frontend via websockets.
162
- updateNotifier :: Plugin Kernel. WalletMode
163
- updateNotifier = [
164
- \ _diffusion -> logError " Not Implemented: updateNotifier [CBR-374]"
165
- ]
162
+ -- | A @Plugin@ to store updates proposal received from the blockchain
163
+ updateWatcher :: Plugin Kernel. WalletMode
164
+ updateWatcher = pure $ \ _diffusion -> do
165
+ modifyLoggerName (const " update-watcher-plugin" ) $ do
166
+ w <- Kernel. getWallet
167
+ forever $ liftIO $ do
168
+ newUpdate <- WalletLayer. waitForUpdate w
169
+ logInfo " A new update was found!"
170
+ WalletLayer. addUpdate w . cpsSoftwareVersion $ newUpdate
0 commit comments