File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
ouroboros-consensus/src/unstable-mempool-test-utils/Test/Consensus/Mempool Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 1+ {-# LANGUAGE BangPatterns #-}
2+ {-# LANGUAGE LambdaCase #-}
3+
4+ module Test.Consensus.Mempool.Multiplicity (leastMultiplicity ) where
5+
6+ import Ouroboros.Consensus.Mock.Ledger.Block (simpleBlockTxCapacity )
7+ import Ouroboros.Network.SizeInBytes (SizeInBytes )
8+
9+ -- | This function accurately mimics how
10+ -- 'Ouroboros.Consensus.Mempool.Update.shouldTryToAddTx' would behave when
11+ -- adding valid transactions of the following sizes, in order, to an initially
12+ -- empty mempool.
13+ leastMultiplicity :: [SizeInBytes ] -> Int
14+ leastMultiplicity =
15+ go 1 0
16+ where
17+ go ! n ! acc = \ case
18+ [] -> n
19+ x: xs ->
20+ if acc + x <= simpleBlockTxCapacity
21+ then go n (acc + x) xs
22+ else go (n + 1 ) x xs
You can’t perform that action at this time.
0 commit comments