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

Commit 32309dd

Browse files
committed
Implement new node settings using coupled NodeStateAdaptor
1 parent 2ea74a1 commit 32309dd

File tree

1 file changed

+20
-4
lines changed
  • wallet/src/Cardano/Wallet/WalletLayer/Kernel

1 file changed

+20
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{-# LANGUAGE LambdaCase #-}
2+
13
module Cardano.Wallet.WalletLayer.Kernel.Settings (
24
getNodeSettings
35
) where
@@ -7,29 +9,43 @@ import Universum
79
import qualified Data.Text as T
810
import Data.Time.Units (Millisecond)
911

12+
import Pos.Core (TxFeePolicy (..))
13+
import qualified Pos.Node.API as Node
1014
import Pos.Util.CompileInfo (CompileTimeInfo, ctiGitRevision)
1115

1216
import Cardano.Wallet.API.V1.Types (V1 (..))
1317
import qualified Cardano.Wallet.API.V1.Types as V1
1418
import qualified Cardano.Wallet.Kernel.Internal as Kernel
1519
import Cardano.Wallet.Kernel.NodeStateAdaptor (NodeStateAdaptor)
16-
import qualified Cardano.Wallet.Kernel.NodeStateAdaptor as Node
20+
import qualified Cardano.Wallet.Kernel.NodeStateAdaptor as KNode
1721

1822
import Paths_cardano_wallet (version)
1923

2024
getNodeSettings :: MonadIO m => Kernel.PassiveWallet -> m V1.NodeSettings
2125
getNodeSettings w = liftIO $
2226
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)
2531
<*> 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)
2736
where
2837
mkSlotDuration :: Millisecond -> V1.SlotDuration
2938
mkSlotDuration = V1.mkSlotDuration . fromIntegral
3039

3140
mkGitRevision :: CompileTimeInfo -> Text
3241
mkGitRevision = T.replace "\n" mempty . ctiGitRevision
3342

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+
3450
node :: NodeStateAdaptor IO
3551
node = w ^. Kernel.walletNode

0 commit comments

Comments
 (0)