@@ -23,7 +23,8 @@ import UTxO.Generator
23
23
import Wallet.Inductive
24
24
import Wallet.Inductive.Generator
25
25
26
- import Pos.Core ( TxSizeLinear , calculateTxSizeLinear )
26
+ import Pos.Core (TxSizeLinear , calculateTxSizeLinear )
27
+ import Pos.Crypto (RequiresNetworkMagic (.. ))
27
28
import Serokell.Data.Memory.Units (Byte , fromBytes )
28
29
29
30
{- ------------------------------------------------------------------------------
@@ -51,20 +52,21 @@ data GeneratorModel h a = GeneratorModel {
51
52
, gmMaxNumOurs :: Int
52
53
53
54
-- | Estimate fees
54
- , gmEstimateFee :: Int -> [Value ] -> Value
55
+ , gmEstimateFee :: RequiresNetworkMagic -> Int -> [Value ] -> Value
55
56
}
56
57
57
- genChainUsingModel :: (Hash h a , Ord a ) => GeneratorModel h a -> Gen (Chain h a )
58
- genChainUsingModel GeneratorModel {.. } =
58
+ genChainUsingModel :: (Hash h a , Ord a )
59
+ => RequiresNetworkMagic -> GeneratorModel h a -> Gen (Chain h a )
60
+ genChainUsingModel rnm GeneratorModel {.. } =
59
61
evalStateT (genChain params) initState
60
62
where
61
- params = defChainParams gmEstimateFee gmAllAddresses
63
+ params = defChainParams ( gmEstimateFee rnm) gmAllAddresses
62
64
initUtxo = utxoRestrictToAddr (`elem` gmAllAddresses) $ trUtxo gmBoot
63
65
initState = initTrState initUtxo 1
64
66
65
- genInductiveUsingModel :: (Hash h a , Ord a )
66
- = > GeneratorModel h a -> Gen (Inductive h a )
67
- genInductiveUsingModel GeneratorModel {.. } = do
67
+ genInductiveUsingModel :: (Hash h a , Ord a ) => RequiresNetworkMagic
68
+ - > GeneratorModel h a -> Gen (Inductive h a )
69
+ genInductiveUsingModel rnm GeneratorModel {.. } = do
68
70
numOurs <- choose (1 , min (length potentialOurs) gmMaxNumOurs)
69
71
addrs' <- shuffle potentialOurs
70
72
let ours = Set. fromList (take numOurs addrs')
@@ -76,7 +78,8 @@ genInductiveUsingModel GeneratorModel{..} = do
76
78
}
77
79
where
78
80
potentialOurs = filter gmPotentialOurs gmAllAddresses
79
- params ours = defEventsParams gmEstimateFee gmAllAddresses ours initUtxo
81
+ params ours =
82
+ defEventsParams (gmEstimateFee rnm) gmAllAddresses ours initUtxo
80
83
initUtxo = utxoRestrictToAddr (`elem` gmAllAddresses) $ trUtxo gmBoot
81
84
initState = initEventsGlobalState 1
82
85
@@ -91,7 +94,7 @@ simpleModel :: GeneratorModel GivenHash Char
91
94
simpleModel = GeneratorModel {
92
95
gmAllAddresses = addrs
93
96
, gmPotentialOurs = \ _ -> True
94
- , gmEstimateFee = \ _ _ -> 0
97
+ , gmEstimateFee = \ _ _ _ -> 0
95
98
, gmMaxNumOurs = 3
96
99
, gmBoot = Transaction {
97
100
trFresh = fromIntegral (length addrs) * initBal
@@ -176,9 +179,12 @@ estimateSize saa sta ins outs
176
179
-- NOTE: The average size of @Attributes AddrAttributes@ and
177
180
-- the transaction attributes @Attributes ()@ are both hard-coded
178
181
-- here with some (hopefully) realistic values.
179
- estimateCardanoFee :: TxSizeLinear -> Int -> [Value ] -> Value
180
- estimateCardanoFee linearFeePolicy ins outs
181
- = round (calculateTxSizeLinear linearFeePolicy (estimateSize 128 16 ins outs))
182
+ estimateCardanoFee :: TxSizeLinear -> RequiresNetworkMagic -> Int -> [Value ] -> Value
183
+ estimateCardanoFee linearFeePolicy rnm ins outs
184
+ = round (calculateTxSizeLinear linearFeePolicy (estimateSize addrAttrSize 16 ins outs))
185
+ where
186
+ addrAttrSize = 128 + (case rnm of NMMustBeNothing -> 0
187
+ NMMustBeJust -> 4 )
182
188
183
189
{- ------------------------------------------------------------------------------
184
190
Auxiliary
0 commit comments