1
+ {-# LANGUAGE LambdaCase #-}
2
+
1
3
module Cardano.Wallet.WalletLayer.Kernel.Settings (
2
4
getNodeSettings
3
5
) where
@@ -7,29 +9,43 @@ import Universum
7
9
import qualified Data.Text as T
8
10
import Data.Time.Units (Millisecond )
9
11
12
+ import Pos.Core (TxFeePolicy (.. ))
13
+ import qualified Pos.Node.API as Node
10
14
import Pos.Util.CompileInfo (CompileTimeInfo , ctiGitRevision )
11
15
12
16
import Cardano.Wallet.API.V1.Types (V1 (.. ))
13
17
import qualified Cardano.Wallet.API.V1.Types as V1
14
18
import qualified Cardano.Wallet.Kernel.Internal as Kernel
15
19
import Cardano.Wallet.Kernel.NodeStateAdaptor (NodeStateAdaptor )
16
- import qualified Cardano.Wallet.Kernel.NodeStateAdaptor as Node
20
+ import qualified Cardano.Wallet.Kernel.NodeStateAdaptor as KNode
17
21
18
22
import Paths_cardano_wallet (version )
19
23
20
24
getNodeSettings :: MonadIO m => Kernel. PassiveWallet -> m V1. NodeSettings
21
25
getNodeSettings w = liftIO $
22
26
V1. NodeSettings
23
- <$> (mkSlotDuration <$> Node. getNextEpochSlotDuration node)
24
- <*> (V1 <$> Node. curSoftwareVersion node)
27
+ <$> (V1 <$> KNode. getTipSlotId node)
28
+ <*> (mkSlotDuration <$> KNode. getNextEpochSlotDuration node)
29
+ <*> (V1 <$> KNode. getSlotCount node)
30
+ <*> (V1 <$> KNode. curSoftwareVersion node)
25
31
<*> pure (V1 version)
26
- <*> (mkGitRevision <$> Node. compileInfo node)
32
+ <*> (mkGitRevision <$> KNode. compileInfo node)
33
+ <*> (Node. mkMaxTxSize . fromIntegral <$> KNode. getMaxTxSize node)
34
+ <*> (Node. fromCorePolicy <$> (KNode. getFeePolicy node >>= mkFeePolicy))
35
+ <*> (mkSecurityParameter <$> KNode. getSecurityParameter node)
27
36
where
28
37
mkSlotDuration :: Millisecond -> V1. SlotDuration
29
38
mkSlotDuration = V1. mkSlotDuration . fromIntegral
30
39
31
40
mkGitRevision :: CompileTimeInfo -> Text
32
41
mkGitRevision = T. replace " \n " mempty . ctiGitRevision
33
42
43
+ mkSecurityParameter (KNode. SecurityParameter i) =
44
+ Node. SecurityParameter i
45
+
46
+ mkFeePolicy = \ case
47
+ TxFeePolicyTxSizeLinear a -> return a
48
+ _ -> fail " getNodeSettings: Unsupported / Unknown fee policy."
49
+
34
50
node :: NodeStateAdaptor IO
35
51
node = w ^. Kernel. walletNode
0 commit comments