@@ -23,7 +23,6 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
23
23
CChainState chainstate{&mempool, blockman};
24
24
chainstate.InitCoinsDB (/* cache_size_bytes*/ 1 << 10 , /* in_memory*/ true , /* should_wipe*/ false );
25
25
WITH_LOCK (::cs_main, chainstate.InitCoinsCache (1 << 10 ));
26
- CTxMemPool tx_pool{};
27
26
28
27
constexpr bool is_64_bit = sizeof (void *) == 8 ;
29
28
@@ -57,7 +56,7 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
57
56
58
57
// Without any coins in the cache, we shouldn't need to flush.
59
58
BOOST_CHECK_EQUAL (
60
- chainstate.GetCoinsCacheSizeState (&tx_pool, MAX_COINS_CACHE_BYTES, /* max_mempool_size_bytes*/ 0 ),
59
+ chainstate.GetCoinsCacheSizeState (MAX_COINS_CACHE_BYTES, /* max_mempool_size_bytes*/ 0 ),
61
60
CoinsCacheSizeState::OK);
62
61
63
62
// If the initial memory allocations of cacheCoins don't match these common
@@ -72,7 +71,7 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
72
71
}
73
72
74
73
BOOST_CHECK_EQUAL (
75
- chainstate.GetCoinsCacheSizeState (&tx_pool, MAX_COINS_CACHE_BYTES, /* max_mempool_size_bytes*/ 0 ),
74
+ chainstate.GetCoinsCacheSizeState (MAX_COINS_CACHE_BYTES, /* max_mempool_size_bytes*/ 0 ),
76
75
CoinsCacheSizeState::CRITICAL);
77
76
78
77
BOOST_TEST_MESSAGE (" Exiting cache flush tests early due to unsupported arch" );
@@ -93,34 +92,34 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
93
92
print_view_mem_usage (view);
94
93
BOOST_CHECK_EQUAL (view.AccessCoin (res).DynamicMemoryUsage (), COIN_SIZE);
95
94
BOOST_CHECK_EQUAL (
96
- chainstate.GetCoinsCacheSizeState (&tx_pool, MAX_COINS_CACHE_BYTES, /* max_mempool_size_bytes*/ 0 ),
95
+ chainstate.GetCoinsCacheSizeState (MAX_COINS_CACHE_BYTES, /* max_mempool_size_bytes*/ 0 ),
97
96
CoinsCacheSizeState::OK);
98
97
}
99
98
100
99
// Adding some additional coins will push us over the edge to CRITICAL.
101
100
for (int i{0 }; i < 4 ; ++i) {
102
101
add_coin (view);
103
102
print_view_mem_usage (view);
104
- if (chainstate.GetCoinsCacheSizeState (&tx_pool, MAX_COINS_CACHE_BYTES, /* max_mempool_size_bytes*/ 0 ) ==
103
+ if (chainstate.GetCoinsCacheSizeState (MAX_COINS_CACHE_BYTES, /* max_mempool_size_bytes*/ 0 ) ==
105
104
CoinsCacheSizeState::CRITICAL) {
106
105
break ;
107
106
}
108
107
}
109
108
110
109
BOOST_CHECK_EQUAL (
111
- chainstate.GetCoinsCacheSizeState (&tx_pool, MAX_COINS_CACHE_BYTES, /* max_mempool_size_bytes*/ 0 ),
110
+ chainstate.GetCoinsCacheSizeState (MAX_COINS_CACHE_BYTES, /* max_mempool_size_bytes*/ 0 ),
112
111
CoinsCacheSizeState::CRITICAL);
113
112
114
113
// Passing non-zero max mempool usage should allow us more headroom.
115
114
BOOST_CHECK_EQUAL (
116
- chainstate.GetCoinsCacheSizeState (&tx_pool, MAX_COINS_CACHE_BYTES, /* max_mempool_size_bytes*/ 1 << 10 ),
115
+ chainstate.GetCoinsCacheSizeState (MAX_COINS_CACHE_BYTES, /* max_mempool_size_bytes*/ 1 << 10 ),
117
116
CoinsCacheSizeState::OK);
118
117
119
118
for (int i{0 }; i < 3 ; ++i) {
120
119
add_coin (view);
121
120
print_view_mem_usage (view);
122
121
BOOST_CHECK_EQUAL (
123
- chainstate.GetCoinsCacheSizeState (&tx_pool, MAX_COINS_CACHE_BYTES, /* max_mempool_size_bytes*/ 1 << 10 ),
122
+ chainstate.GetCoinsCacheSizeState (MAX_COINS_CACHE_BYTES, /* max_mempool_size_bytes*/ 1 << 10 ),
124
123
CoinsCacheSizeState::OK);
125
124
}
126
125
@@ -136,31 +135,31 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
136
135
BOOST_CHECK (usage_percentage >= 0.9 );
137
136
BOOST_CHECK (usage_percentage < 1 );
138
137
BOOST_CHECK_EQUAL (
139
- chainstate.GetCoinsCacheSizeState (&tx_pool, MAX_COINS_CACHE_BYTES, 1 << 10 ),
138
+ chainstate.GetCoinsCacheSizeState (MAX_COINS_CACHE_BYTES, 1 << 10 ),
140
139
CoinsCacheSizeState::LARGE);
141
140
}
142
141
143
142
// Using the default max_* values permits way more coins to be added.
144
143
for (int i{0 }; i < 1000 ; ++i) {
145
144
add_coin (view);
146
145
BOOST_CHECK_EQUAL (
147
- chainstate.GetCoinsCacheSizeState (&tx_pool ),
146
+ chainstate.GetCoinsCacheSizeState (),
148
147
CoinsCacheSizeState::OK);
149
148
}
150
149
151
150
// Flushing the view doesn't take us back to OK because cacheCoins has
152
151
// preallocated memory that doesn't get reclaimed even after flush.
153
152
154
153
BOOST_CHECK_EQUAL (
155
- chainstate.GetCoinsCacheSizeState (&tx_pool, MAX_COINS_CACHE_BYTES, 0 ),
154
+ chainstate.GetCoinsCacheSizeState (MAX_COINS_CACHE_BYTES, 0 ),
156
155
CoinsCacheSizeState::CRITICAL);
157
156
158
157
view.SetBestBlock (InsecureRand256 ());
159
158
BOOST_CHECK (view.Flush ());
160
159
print_view_mem_usage (view);
161
160
162
161
BOOST_CHECK_EQUAL (
163
- chainstate.GetCoinsCacheSizeState (&tx_pool, MAX_COINS_CACHE_BYTES, 0 ),
162
+ chainstate.GetCoinsCacheSizeState (MAX_COINS_CACHE_BYTES, 0 ),
164
163
CoinsCacheSizeState::CRITICAL);
165
164
}
166
165
0 commit comments