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

Commit 0fa086e

Browse files
committed
[CDEC-505] Move Pos.Core.Genesis to Pos.Chain.Genesis
1 parent 87c0957 commit 0fa086e

27 files changed

+184
-174
lines changed

server/Main.hs

+27-27
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import Universum
1111
import Control.Concurrent.STM (newTQueueIO)
1212
import Ntp.Client (NtpConfiguration, NtpStatus, ntpClientSettings,
1313
withNtpClient)
14+
import Pos.Chain.Genesis as Genesis (Config (..))
1415
import Pos.Chain.Ssc (SscParams)
1516
import Pos.Chain.Txp (TxpConfiguration)
1617
import qualified Pos.Client.CLI as CLI
1718
import Pos.Context (ncUserSecret)
18-
import Pos.Core as Core (Config (..))
1919
import Pos.DB.DB (initNodeDBs)
2020
import Pos.DB.Txp (txpGlobalSettings)
2121
import Pos.Infra.Diffusion.Types (Diffusion)
@@ -61,26 +61,26 @@ defaultLoggerName = "node"
6161
-- | The legacy function responsible for starting a Cardano edge node plus a
6262
-- number of extra plugins.
6363
actionWithLegacyWallet :: (HasConfigurations, HasCompileInfo)
64-
=> Core.Config
64+
=> Genesis.Config
6565
-> WalletConfiguration
6666
-> TxpConfiguration
6767
-> SscParams
6868
-> NodeParams
6969
-> NtpConfiguration
7070
-> WalletBackendParams
7171
-> IO ()
72-
actionWithLegacyWallet coreConfig walletConfig txpConfig sscParams nodeParams ntpConfig wArgs@WalletBackendParams {..} =
72+
actionWithLegacyWallet genesisConfig walletConfig txpConfig sscParams nodeParams ntpConfig wArgs@WalletBackendParams {..} =
7373
bracketWalletWebDB (walletDbPath walletDbOptions) (walletRebuildDb walletDbOptions) $ \db ->
7474
bracketWalletWS $ \conn ->
7575
bracketNodeResources
76-
coreConfig
76+
genesisConfig
7777
nodeParams
7878
sscParams
79-
(txpGlobalSettings coreConfig txpConfig)
80-
(initNodeDBs coreConfig) $ \nr@NodeResources {..} -> do
79+
(txpGlobalSettings genesisConfig txpConfig)
80+
(initNodeDBs genesisConfig) $ \nr@NodeResources {..} -> do
8181
syncQueue <- liftIO newTQueueIO
8282
ntpStatus <- withNtpClient (ntpClientSettings ntpConfig)
83-
runWRealMode coreConfig txpConfig db conn syncQueue nr (mainAction ntpStatus nr)
83+
runWRealMode genesisConfig txpConfig db conn syncQueue nr (mainAction ntpStatus nr)
8484
where
8585
mainAction ntpStatus = runNodeWithInit ntpStatus $ do
8686
when (walletFlushDb walletDbOptions) $ do
@@ -95,7 +95,7 @@ actionWithLegacyWallet coreConfig walletConfig txpConfig sscParams nodeParams nt
9595

9696
runNodeWithInit ntpStatus init' nr diffusion = do
9797
_ <- init'
98-
runNode coreConfig txpConfig nr (plugins ntpStatus) diffusion
98+
runNode genesisConfig txpConfig nr (plugins ntpStatus) diffusion
9999

100100
syncWallets :: WalletWebMode ()
101101
syncWallets = do
@@ -106,34 +106,34 @@ actionWithLegacyWallet coreConfig walletConfig txpConfig sscParams nodeParams nt
106106
plugins :: TVar NtpStatus -> LegacyPlugins.Plugin WalletWebMode
107107
plugins ntpStatus =
108108
mconcat [ LegacyPlugins.conversation wArgs
109-
, LegacyPlugins.legacyWalletBackend coreConfig walletConfig txpConfig wArgs ntpStatus
109+
, LegacyPlugins.legacyWalletBackend genesisConfig walletConfig txpConfig wArgs ntpStatus
110110
, LegacyPlugins.walletDocumentation wArgs
111111
, LegacyPlugins.acidCleanupWorker wArgs
112-
, LegacyPlugins.syncWalletWorker coreConfig
113-
, LegacyPlugins.resubmitterPlugin coreConfig txpConfig
112+
, LegacyPlugins.syncWalletWorker genesisConfig
113+
, LegacyPlugins.resubmitterPlugin genesisConfig txpConfig
114114
, LegacyPlugins.notifierPlugin
115115
]
116116

117117
-- | The "workhorse" responsible for starting a Cardano edge node plus a number of extra plugins.
118118
actionWithWallet :: (HasConfigurations, HasCompileInfo)
119-
=> Core.Config
119+
=> Genesis.Config
120120
-> TxpConfiguration
121121
-> SscParams
122122
-> NodeParams
123123
-> NtpConfiguration
124124
-> NewWalletBackendParams
125125
-> IO ()
126-
actionWithWallet coreConfig txpConfig sscParams nodeParams ntpConfig params =
126+
actionWithWallet genesisConfig txpConfig sscParams nodeParams ntpConfig params =
127127
bracketNodeResources
128-
coreConfig
128+
genesisConfig
129129
nodeParams
130130
sscParams
131-
(txpGlobalSettings coreConfig txpConfig)
132-
(initNodeDBs coreConfig) $ \nr -> do
131+
(txpGlobalSettings genesisConfig txpConfig)
132+
(initNodeDBs genesisConfig) $ \nr -> do
133133
ntpStatus <- withNtpClient (ntpClientSettings ntpConfig)
134134
userSecret <- readTVarIO (ncUserSecret $ nrContext nr)
135135
let nodeState = NodeStateAdaptor.newNodeStateAdaptor
136-
coreConfig
136+
genesisConfig
137137
nr
138138
ntpStatus
139139
liftIO $ Keystore.bracketLegacyKeystore userSecret $ \keystore -> do
@@ -144,13 +144,13 @@ actionWithWallet coreConfig txpConfig sscParams nodeParams ntpConfig params =
144144
})
145145
WalletLayer.Kernel.bracketPassiveWallet dbMode logMessage' keystore nodeState $ \walletLayer passiveWallet -> do
146146
Kernel.init passiveWallet
147-
Kernel.Mode.runWalletMode coreConfig
147+
Kernel.Mode.runWalletMode genesisConfig
148148
txpConfig
149149
nr
150150
walletLayer
151151
(mainAction (walletLayer, passiveWallet) nr dbMode)
152152
where
153-
pm = configProtocolMagic coreConfig
153+
pm = configProtocolMagic genesisConfig
154154
mainAction
155155
:: (PassiveWalletLayer IO, PassiveWallet)
156156
-> NodeResources ext
@@ -163,7 +163,7 @@ actionWithWallet coreConfig txpConfig sscParams nodeParams ntpConfig params =
163163
-> NodeResources ext
164164
-> Kernel.DatabaseMode
165165
-> (Diffusion Kernel.Mode.WalletMode -> Kernel.Mode.WalletMode ())
166-
runNodeWithInit w nr dbMode = runNode coreConfig txpConfig nr (plugins w dbMode)
166+
runNodeWithInit w nr dbMode = runNode genesisConfig txpConfig nr (plugins w dbMode)
167167

168168
plugins :: (PassiveWalletLayer IO, PassiveWallet)
169169
-> Kernel.DatabaseMode
@@ -203,33 +203,33 @@ actionWithWallet coreConfig txpConfig sscParams nodeParams ntpConfig params =
203203
startEdgeNode :: HasCompileInfo => WalletStartupOptions -> IO ()
204204
startEdgeNode wso =
205205
withConfigurations blPath dumpGenesisPath dumpConfiguration conf $
206-
\coreConfig walletConfig txpConfig ntpConfig -> do
207-
(sscParams, nodeParams) <- getParameters coreConfig
206+
\genesisConfig walletConfig txpConfig ntpConfig -> do
207+
(sscParams, nodeParams) <- getParameters genesisConfig
208208

209209
case wsoWalletBackendParams wso of
210210
WalletLegacy legacyParams -> actionWithLegacyWallet
211-
coreConfig
211+
genesisConfig
212212
walletConfig
213213
txpConfig
214214
sscParams
215215
nodeParams
216216
ntpConfig
217217
legacyParams
218218
WalletNew newParams -> actionWithWallet
219-
coreConfig
219+
genesisConfig
220220
txpConfig
221221
sscParams
222222
nodeParams
223223
ntpConfig
224224
newParams
225225
where
226-
getParameters :: Core.Config -> IO (SscParams, NodeParams)
227-
getParameters coreConfig = do
226+
getParameters :: Genesis.Config -> IO (SscParams, NodeParams)
227+
getParameters genesisConfig = do
228228

229229
(currentParams, Just gtParams) <- CLI.getNodeParams defaultLoggerName
230230
(wsoNodeArgs wso)
231231
nodeArgs
232-
(configGeneratedSecrets coreConfig)
232+
(configGeneratedSecrets genesisConfig)
233233

234234
logInfo "Wallet is enabled!"
235235

src/Cardano/Wallet/API/Internal/LegacyHandlers.hs

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import Control.Monad.Catch (MonadThrow)
1414
import Servant
1515
import UnliftIO (MonadUnliftIO)
1616

17+
import Pos.Chain.Genesis as Genesis (Config)
1718
import qualified Pos.Client.KeyStorage as V0
18-
import Pos.Core as Core (Config)
1919
import Pos.Core.Update (SoftwareVersion)
2020
import Pos.Crypto (emptyPassphrase)
2121
import Pos.Util (HasLens (..))
@@ -38,17 +38,17 @@ import Cardano.Wallet.Server.CLI (RunMode (..), isDebugMode)
3838
handlers
3939
:: HasUpdateConfiguration
4040
=> (forall a. MonadV1 a -> Handler a)
41-
-> Core.Config
41+
-> Genesis.Config
4242
-> RunMode
4343
-> Server Internal.API
44-
handlers naturalTransformation coreConfig runMode =
44+
handlers naturalTransformation genesisConfig runMode =
4545
let
4646
handlers' =
4747
nextUpdate
4848
:<|> V0.applyUpdate
4949
:<|> V0.postponeUpdate
5050
:<|> resetWalletState runMode
51-
:<|> importWallet coreConfig
51+
:<|> importWallet genesisConfig
5252
in
5353
hoistServer (Proxy @Internal.API) naturalTransformation handlers'
5454

@@ -78,11 +78,11 @@ importWallet
7878
, MonadUnliftIO m
7979
, HasLens SyncQueue ctx SyncQueue
8080
)
81-
=> Core.Config
81+
=> Genesis.Config
8282
-> WalletImport
8383
-> m (WalletResponse Wallet)
84-
importWallet coreConfig WalletImport{..} = do
84+
importWallet genesisConfig WalletImport{..} = do
8585
fp <- migrate wiFilePath
86-
v0Wallet <- V0.importWallet coreConfig (maybe emptyPassphrase unV1 wiSpendingPassword) fp
86+
v0Wallet <- V0.importWallet genesisConfig (maybe emptyPassphrase unV1 wiSpendingPassword) fp
8787
snapshot <- V0.askWalletSnapshot
8888
single <$> Legacy.addWalletInfo snapshot v0Wallet

src/Cardano/Wallet/API/V0/Handlers.hs

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module Cardano.Wallet.API.V0.Handlers where
33

44
import qualified Cardano.Wallet.API.V0 as V0
55
import Ntp.Client (NtpStatus)
6+
import Pos.Chain.Genesis as Genesis (Config)
67
import Pos.Chain.Txp (TxpConfiguration)
7-
import Pos.Core as Core (Config)
88
import Pos.Infra.Diffusion.Types (Diffusion (sendTx))
99
import Pos.Util.CompileInfo (HasCompileInfo)
1010
import Pos.Wallet.Web.Mode (MonadFullWalletWebMode)
@@ -20,12 +20,12 @@ import Universum
2020
-- a Servant's @Handler@, I can give you back a "plain old" Server.
2121
handlers :: ( MonadFullWalletWebMode ctx m, HasCompileInfo )
2222
=> (forall a. m a -> Handler a)
23-
-> Core.Config
23+
-> Genesis.Config
2424
-> TxpConfiguration
2525
-> Diffusion m
2626
-> TVar NtpStatus
2727
-> Server V0.API
28-
handlers naturalTransformation coreConfig txpConfig diffusion ntpStatus = hoistServer
28+
handlers naturalTransformation genesisConfig txpConfig diffusion ntpStatus = hoistServer
2929
(Proxy @V0.API)
3030
naturalTransformation
31-
(V0.servantHandlers coreConfig txpConfig ntpStatus (sendTx diffusion))
31+
(V0.servantHandlers genesisConfig txpConfig ntpStatus (sendTx diffusion))

src/Cardano/Wallet/API/V1/LegacyHandlers.hs

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ module Cardano.Wallet.API.V1.LegacyHandlers where
1010
import Universum
1111

1212
import Ntp.Client (NtpStatus)
13+
import Pos.Chain.Genesis as Genesis (Config)
1314
import Pos.Chain.Txp (TxpConfiguration)
14-
import Pos.Core as Core (Config)
1515
import Pos.Infra.Diffusion.Types (Diffusion (sendTx))
1616

1717
import qualified Cardano.Wallet.API.V1 as V1
@@ -41,16 +41,16 @@ handlers :: ( HasConfigurations
4141
, HasCompileInfo
4242
)
4343
=> (forall a. MonadV1 a -> Handler a)
44-
-> Core.Config
44+
-> Genesis.Config
4545
-> TxpConfiguration
4646
-> Diffusion MonadV1
4747
-> TVar NtpStatus
4848
-> Server V1.API
49-
handlers naturalTransformation coreConfig txpConfig diffusion ntpStatus =
49+
handlers naturalTransformation genesisConfig txpConfig diffusion ntpStatus =
5050
hoist' (Proxy @Addresses.API) Addresses.handlers
51-
:<|> hoist' (Proxy @Wallets.API) (Wallets.handlers coreConfig)
51+
:<|> hoist' (Proxy @Wallets.API) (Wallets.handlers genesisConfig)
5252
:<|> hoist' (Proxy @Accounts.API) Accounts.handlers
53-
:<|> hoist' (Proxy @Transactions.API) (Transactions.handlers coreConfig txpConfig sendTx')
53+
:<|> hoist' (Proxy @Transactions.API) (Transactions.handlers genesisConfig txpConfig sendTx')
5454
:<|> hoist' (Proxy @Settings.API) Settings.handlers
5555
:<|> hoist' (Proxy @Info.API) (Info.handlers diffusion ntpStatus)
5656
where

src/Cardano/Wallet/API/V1/LegacyHandlers/Transactions.hs

+17-17
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import qualified Data.List.NonEmpty as NE
66
import Formatting (build, sformat)
77
import Servant
88

9+
import Pos.Chain.Genesis as Genesis (Config (..))
910
import Pos.Chain.Txp (TxAux, TxId, TxpConfiguration)
1011
import Pos.Client.Txp.Util (defaultInputSelectionPolicy)
1112
import qualified Pos.Client.Txp.Util as V0
12-
import Pos.Core as Core (Config (..))
1313
import qualified Pos.Core as Core
1414
import qualified Pos.Util.Servant as V0
1515
import qualified Pos.Wallet.WalletMode as V0
@@ -59,25 +59,25 @@ convertTxError err = case err of
5959

6060
handlers
6161
:: HasConfigurations
62-
=> Core.Config
62+
=> Genesis.Config
6363
-> TxpConfiguration
6464
-> (TxAux -> MonadV1 Bool)
6565
-> ServerT Transactions.API MonadV1
66-
handlers coreConfig txpConfig submitTx =
67-
newTransaction coreConfig txpConfig submitTx
66+
handlers genesisConfig txpConfig submitTx =
67+
newTransaction genesisConfig txpConfig submitTx
6868
:<|> allTransactions
69-
:<|> estimateFees coreConfig
70-
:<|> redeemAda coreConfig txpConfig submitTx
69+
:<|> estimateFees genesisConfig
70+
:<|> redeemAda genesisConfig txpConfig submitTx
7171

7272
newTransaction
7373
:: forall ctx m
7474
. (V0.MonadWalletTxFull ctx m)
75-
=> Core.Config
75+
=> Genesis.Config
7676
-> TxpConfiguration
7777
-> (TxAux -> m Bool)
7878
-> Payment
7979
-> m (WalletResponse Transaction)
80-
newTransaction coreConfig txpConfig submitTx Payment {..} = do
80+
newTransaction genesisConfig txpConfig submitTx Payment {..} = do
8181
ws <- V0.askWalletSnapshot
8282
sourceWallet <- migrate (psWalletId pmtSource)
8383

@@ -100,7 +100,7 @@ newTransaction coreConfig txpConfig submitTx Payment {..} = do
100100
addrCoinList <- migrate $ NE.toList pmtDestinations
101101
let (V1 policy) = fromMaybe (V1 defaultInputSelectionPolicy) pmtGroupingPolicy
102102
let batchPayment = V0.NewBatchPayment cAccountId addrCoinList policy
103-
cTx <- V0.newPaymentBatch coreConfig txpConfig submitTx spendingPw batchPayment
103+
cTx <- V0.newPaymentBatch genesisConfig txpConfig submitTx spendingPw batchPayment
104104
single <$> migrate cTx
105105

106106

@@ -145,19 +145,19 @@ allTransactions mwalletId mAccIdx mAddr requestParams fops sops =
145145

146146
estimateFees
147147
:: (MonadThrow m, V0.MonadFees ctx m)
148-
=> Core.Config
148+
=> Genesis.Config
149149
-> Payment
150150
-> m (WalletResponse EstimatedFees)
151-
estimateFees coreConfig Payment{..} = do
151+
estimateFees genesisConfig Payment{..} = do
152152
ws <- V0.askWalletSnapshot
153153
let (V1 policy) = fromMaybe (V1 defaultInputSelectionPolicy) pmtGroupingPolicy
154154
pendingAddrs = V0.getPendingAddresses ws policy
155155
cAccountId <- migrate pmtSource
156-
utxo <- V0.getMoneySourceUtxo (configGenesisData coreConfig)
156+
utxo <- V0.getMoneySourceUtxo (configGenesisData genesisConfig)
157157
ws
158158
(V0.AccountMoneySource cAccountId)
159159
outputs <- V0.coinDistrToOutputs =<< mapM migrate pmtDestinations
160-
efee <- V0.runTxCreator policy (V0.computeTxFee coreConfig pendingAddrs utxo outputs)
160+
efee <- V0.runTxCreator policy (V0.computeTxFee genesisConfig pendingAddrs utxo outputs)
161161
case efee of
162162
Right fee ->
163163
single <$> migrate fee
@@ -166,12 +166,12 @@ estimateFees coreConfig Payment{..} = do
166166

167167
redeemAda
168168
:: HasConfigurations
169-
=> Core.Config
169+
=> Genesis.Config
170170
-> TxpConfiguration
171171
-> (TxAux -> MonadV1 Bool)
172172
-> Redemption
173173
-> MonadV1 (WalletResponse Transaction)
174-
redeemAda coreConfig txpConfig submitTx r = do
174+
redeemAda genesisConfig txpConfig submitTx r = do
175175
let ShieldedRedemptionCode seed = redemptionRedemptionCode r
176176
V1 spendingPassword = redemptionSpendingPassword r
177177
walletId = redemptionWalletId r
@@ -186,10 +186,10 @@ redeemAda coreConfig txpConfig submitTx r = do
186186
, V0.pvSeed = seed
187187
, V0.pvBackupPhrase = phrase
188188
}
189-
V0.redeemAdaPaperVend coreConfig txpConfig submitTx spendingPassword cpaperRedeem
189+
V0.redeemAdaPaperVend genesisConfig txpConfig submitTx spendingPassword cpaperRedeem
190190
Nothing -> do
191191
let cwalletRedeem = V0.CWalletRedeem
192192
{ V0.crWalletId = caccountId
193193
, V0.crSeed = seed
194194
}
195-
V0.redeemAda coreConfig txpConfig submitTx spendingPassword cwalletRedeem
195+
V0.redeemAda genesisConfig txpConfig submitTx spendingPassword cwalletRedeem

0 commit comments

Comments
 (0)