@@ -63,17 +63,17 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
63
63
BOOST_CHECK_EQUAL (testPool.size (), poolSize);
64
64
65
65
// Just the parent:
66
- testPool.addUnchecked (txParent. GetHash (), entry.FromTx (txParent));
66
+ testPool.addUnchecked (entry.FromTx (txParent));
67
67
poolSize = testPool.size ();
68
68
testPool.removeRecursive (txParent);
69
69
BOOST_CHECK_EQUAL (testPool.size (), poolSize - 1 );
70
70
71
71
// Parent, children, grandchildren:
72
- testPool.addUnchecked (txParent. GetHash (), entry.FromTx (txParent));
72
+ testPool.addUnchecked (entry.FromTx (txParent));
73
73
for (int i = 0 ; i < 3 ; i++)
74
74
{
75
- testPool.addUnchecked (txChild[i]. GetHash (), entry.FromTx (txChild[i]));
76
- testPool.addUnchecked (txGrandChild[i]. GetHash (), entry.FromTx (txGrandChild[i]));
75
+ testPool.addUnchecked (entry.FromTx (txChild[i]));
76
+ testPool.addUnchecked (entry.FromTx (txGrandChild[i]));
77
77
}
78
78
// Remove Child[0], GrandChild[0] should be removed:
79
79
poolSize = testPool.size ();
@@ -95,8 +95,8 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
95
95
// Add children and grandchildren, but NOT the parent (simulate the parent being in a block)
96
96
for (int i = 0 ; i < 3 ; i++)
97
97
{
98
- testPool.addUnchecked (txChild[i]. GetHash (), entry.FromTx (txChild[i]));
99
- testPool.addUnchecked (txGrandChild[i]. GetHash (), entry.FromTx (txGrandChild[i]));
98
+ testPool.addUnchecked (entry.FromTx (txChild[i]));
99
+ testPool.addUnchecked (entry.FromTx (txGrandChild[i]));
100
100
}
101
101
// Now remove the parent, as might happen if a block-re-org occurs but the parent cannot be
102
102
// put into the mempool (maybe because it is non-standard):
@@ -128,36 +128,36 @@ BOOST_AUTO_TEST_CASE(MempoolIndexingTest)
128
128
tx1.vout .resize (1 );
129
129
tx1.vout [0 ].scriptPubKey = CScript () << OP_11 << OP_EQUAL;
130
130
tx1.vout [0 ].nValue = 10 * COIN;
131
- pool.addUnchecked (tx1. GetHash (), entry.Fee (10000LL ).FromTx (tx1));
131
+ pool.addUnchecked (entry.Fee (10000LL ).FromTx (tx1));
132
132
133
133
/* highest fee */
134
134
CMutableTransaction tx2 = CMutableTransaction ();
135
135
tx2.vout .resize (1 );
136
136
tx2.vout [0 ].scriptPubKey = CScript () << OP_11 << OP_EQUAL;
137
137
tx2.vout [0 ].nValue = 2 * COIN;
138
- pool.addUnchecked (tx2. GetHash (), entry.Fee (20000LL ).FromTx (tx2));
138
+ pool.addUnchecked (entry.Fee (20000LL ).FromTx (tx2));
139
139
140
140
/* lowest fee */
141
141
CMutableTransaction tx3 = CMutableTransaction ();
142
142
tx3.vout .resize (1 );
143
143
tx3.vout [0 ].scriptPubKey = CScript () << OP_11 << OP_EQUAL;
144
144
tx3.vout [0 ].nValue = 5 * COIN;
145
- pool.addUnchecked (tx3. GetHash (), entry.Fee (0LL ).FromTx (tx3));
145
+ pool.addUnchecked (entry.Fee (0LL ).FromTx (tx3));
146
146
147
147
/* 2nd highest fee */
148
148
CMutableTransaction tx4 = CMutableTransaction ();
149
149
tx4.vout .resize (1 );
150
150
tx4.vout [0 ].scriptPubKey = CScript () << OP_11 << OP_EQUAL;
151
151
tx4.vout [0 ].nValue = 6 * COIN;
152
- pool.addUnchecked (tx4. GetHash (), entry.Fee (15000LL ).FromTx (tx4));
152
+ pool.addUnchecked (entry.Fee (15000LL ).FromTx (tx4));
153
153
154
154
/* equal fee rate to tx1, but newer */
155
155
CMutableTransaction tx5 = CMutableTransaction ();
156
156
tx5.vout .resize (1 );
157
157
tx5.vout [0 ].scriptPubKey = CScript () << OP_11 << OP_EQUAL;
158
158
tx5.vout [0 ].nValue = 11 * COIN;
159
159
entry.nTime = 1 ;
160
- pool.addUnchecked (tx5. GetHash (), entry.Fee (10000LL ).FromTx (tx5));
160
+ pool.addUnchecked (entry.Fee (10000LL ).FromTx (tx5));
161
161
BOOST_CHECK_EQUAL (pool.size (), 5U );
162
162
163
163
std::vector<std::string> sortedOrder;
@@ -175,7 +175,7 @@ BOOST_AUTO_TEST_CASE(MempoolIndexingTest)
175
175
tx6.vout .resize (1 );
176
176
tx6.vout [0 ].scriptPubKey = CScript () << OP_11 << OP_EQUAL;
177
177
tx6.vout [0 ].nValue = 20 * COIN;
178
- pool.addUnchecked (tx6. GetHash (), entry.Fee (0LL ).FromTx (tx6));
178
+ pool.addUnchecked (entry.Fee (0LL ).FromTx (tx6));
179
179
BOOST_CHECK_EQUAL (pool.size (), 6U );
180
180
// Check that at this point, tx6 is sorted low
181
181
sortedOrder.insert (sortedOrder.begin (), tx6.GetHash ().ToString ());
@@ -198,7 +198,7 @@ BOOST_AUTO_TEST_CASE(MempoolIndexingTest)
198
198
BOOST_CHECK_EQUAL (pool.CalculateMemPoolAncestors (entry.Fee (2000000LL ).FromTx (tx7), setAncestorsCalculated, 100 , 1000000 , 1000 , 1000000 , dummy), true );
199
199
BOOST_CHECK (setAncestorsCalculated == setAncestors);
200
200
201
- pool.addUnchecked (tx7. GetHash (), entry.FromTx (tx7), setAncestors);
201
+ pool.addUnchecked (entry.FromTx (tx7), setAncestors);
202
202
BOOST_CHECK_EQUAL (pool.size (), 7U );
203
203
204
204
// Now tx6 should be sorted higher (high fee child): tx7, tx6, tx2, ...
@@ -216,7 +216,7 @@ BOOST_AUTO_TEST_CASE(MempoolIndexingTest)
216
216
tx8.vout [0 ].scriptPubKey = CScript () << OP_11 << OP_EQUAL;
217
217
tx8.vout [0 ].nValue = 10 * COIN;
218
218
setAncestors.insert (pool.mapTx .find (tx7.GetHash ()));
219
- pool.addUnchecked (tx8. GetHash (), entry.Fee (0LL ).Time (2 ).FromTx (tx8), setAncestors);
219
+ pool.addUnchecked (entry.Fee (0LL ).Time (2 ).FromTx (tx8), setAncestors);
220
220
221
221
// Now tx8 should be sorted low, but tx6/tx both high
222
222
sortedOrder.insert (sortedOrder.begin (), tx8.GetHash ().ToString ());
@@ -230,7 +230,7 @@ BOOST_AUTO_TEST_CASE(MempoolIndexingTest)
230
230
tx9.vout .resize (1 );
231
231
tx9.vout [0 ].scriptPubKey = CScript () << OP_11 << OP_EQUAL;
232
232
tx9.vout [0 ].nValue = 1 * COIN;
233
- pool.addUnchecked (tx9. GetHash (), entry.Fee (0LL ).Time (3 ).FromTx (tx9), setAncestors);
233
+ pool.addUnchecked (entry.Fee (0LL ).Time (3 ).FromTx (tx9), setAncestors);
234
234
235
235
// tx9 should be sorted low
236
236
BOOST_CHECK_EQUAL (pool.size (), 9U );
@@ -256,7 +256,7 @@ BOOST_AUTO_TEST_CASE(MempoolIndexingTest)
256
256
BOOST_CHECK_EQUAL (pool.CalculateMemPoolAncestors (entry.Fee (200000LL ).Time (4 ).FromTx (tx10), setAncestorsCalculated, 100 , 1000000 , 1000 , 1000000 , dummy), true );
257
257
BOOST_CHECK (setAncestorsCalculated == setAncestors);
258
258
259
- pool.addUnchecked (tx10. GetHash (), entry.FromTx (tx10), setAncestors);
259
+ pool.addUnchecked (entry.FromTx (tx10), setAncestors);
260
260
261
261
/* *
262
262
* tx8 and tx9 should both now be sorted higher
@@ -301,36 +301,36 @@ BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest)
301
301
tx1.vout .resize (1 );
302
302
tx1.vout [0 ].scriptPubKey = CScript () << OP_11 << OP_EQUAL;
303
303
tx1.vout [0 ].nValue = 10 * COIN;
304
- pool.addUnchecked (tx1. GetHash (), entry.Fee (10000LL ).FromTx (tx1));
304
+ pool.addUnchecked (entry.Fee (10000LL ).FromTx (tx1));
305
305
306
306
/* highest fee */
307
307
CMutableTransaction tx2 = CMutableTransaction ();
308
308
tx2.vout .resize (1 );
309
309
tx2.vout [0 ].scriptPubKey = CScript () << OP_11 << OP_EQUAL;
310
310
tx2.vout [0 ].nValue = 2 * COIN;
311
- pool.addUnchecked (tx2. GetHash (), entry.Fee (20000LL ).FromTx (tx2));
311
+ pool.addUnchecked (entry.Fee (20000LL ).FromTx (tx2));
312
312
uint64_t tx2Size = GetVirtualTransactionSize (tx2);
313
313
314
314
/* lowest fee */
315
315
CMutableTransaction tx3 = CMutableTransaction ();
316
316
tx3.vout .resize (1 );
317
317
tx3.vout [0 ].scriptPubKey = CScript () << OP_11 << OP_EQUAL;
318
318
tx3.vout [0 ].nValue = 5 * COIN;
319
- pool.addUnchecked (tx3. GetHash (), entry.Fee (0LL ).FromTx (tx3));
319
+ pool.addUnchecked (entry.Fee (0LL ).FromTx (tx3));
320
320
321
321
/* 2nd highest fee */
322
322
CMutableTransaction tx4 = CMutableTransaction ();
323
323
tx4.vout .resize (1 );
324
324
tx4.vout [0 ].scriptPubKey = CScript () << OP_11 << OP_EQUAL;
325
325
tx4.vout [0 ].nValue = 6 * COIN;
326
- pool.addUnchecked (tx4. GetHash (), entry.Fee (15000LL ).FromTx (tx4));
326
+ pool.addUnchecked (entry.Fee (15000LL ).FromTx (tx4));
327
327
328
328
/* equal fee rate to tx1, but newer */
329
329
CMutableTransaction tx5 = CMutableTransaction ();
330
330
tx5.vout .resize (1 );
331
331
tx5.vout [0 ].scriptPubKey = CScript () << OP_11 << OP_EQUAL;
332
332
tx5.vout [0 ].nValue = 11 * COIN;
333
- pool.addUnchecked (tx5. GetHash (), entry.Fee (10000LL ).FromTx (tx5));
333
+ pool.addUnchecked (entry.Fee (10000LL ).FromTx (tx5));
334
334
BOOST_CHECK_EQUAL (pool.size (), 5U );
335
335
336
336
std::vector<std::string> sortedOrder;
@@ -359,7 +359,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest)
359
359
tx6.vout [0 ].nValue = 20 * COIN;
360
360
uint64_t tx6Size = GetVirtualTransactionSize (tx6);
361
361
362
- pool.addUnchecked (tx6. GetHash (), entry.Fee (0LL ).FromTx (tx6));
362
+ pool.addUnchecked (entry.Fee (0LL ).FromTx (tx6));
363
363
BOOST_CHECK_EQUAL (pool.size (), 6U );
364
364
// Ties are broken by hash
365
365
if (tx3.GetHash () < tx6.GetHash ())
@@ -381,7 +381,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest)
381
381
/* set the fee to just below tx2's feerate when including ancestor */
382
382
CAmount fee = (20000 /tx2Size)*(tx7Size + tx6Size) - 1 ;
383
383
384
- pool.addUnchecked (tx7. GetHash (), entry.Fee (fee).FromTx (tx7));
384
+ pool.addUnchecked (entry.Fee (fee).FromTx (tx7));
385
385
BOOST_CHECK_EQUAL (pool.size (), 7U );
386
386
sortedOrder.insert (sortedOrder.begin ()+1 , tx7.GetHash ().ToString ());
387
387
CheckSort<ancestor_score>(pool, sortedOrder);
@@ -413,7 +413,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest)
413
413
// Check that we sort by min(feerate, ancestor_feerate):
414
414
// set the fee so that the ancestor feerate is above tx1/5,
415
415
// but the transaction's own feerate is lower
416
- pool.addUnchecked (tx8. GetHash (), entry.Fee (5000LL ).FromTx (tx8));
416
+ pool.addUnchecked (entry.Fee (5000LL ).FromTx (tx8));
417
417
sortedOrder.insert (sortedOrder.end ()-1 , tx8.GetHash ().ToString ());
418
418
CheckSort<ancestor_score>(pool, sortedOrder);
419
419
}
@@ -431,15 +431,15 @@ BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest)
431
431
tx1.vout .resize (1 );
432
432
tx1.vout [0 ].scriptPubKey = CScript () << OP_1 << OP_EQUAL;
433
433
tx1.vout [0 ].nValue = 10 * COIN;
434
- pool.addUnchecked (tx1. GetHash (), entry.Fee (10000LL ).FromTx (tx1));
434
+ pool.addUnchecked (entry.Fee (10000LL ).FromTx (tx1));
435
435
436
436
CMutableTransaction tx2 = CMutableTransaction ();
437
437
tx2.vin .resize (1 );
438
438
tx2.vin [0 ].scriptSig = CScript () << OP_2;
439
439
tx2.vout .resize (1 );
440
440
tx2.vout [0 ].scriptPubKey = CScript () << OP_2 << OP_EQUAL;
441
441
tx2.vout [0 ].nValue = 10 * COIN;
442
- pool.addUnchecked (tx2. GetHash (), entry.Fee (5000LL ).FromTx (tx2));
442
+ pool.addUnchecked (entry.Fee (5000LL ).FromTx (tx2));
443
443
444
444
pool.TrimToSize (pool.DynamicMemoryUsage ()); // should do nothing
445
445
BOOST_CHECK (pool.exists (tx1.GetHash ()));
@@ -449,15 +449,15 @@ BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest)
449
449
BOOST_CHECK (pool.exists (tx1.GetHash ()));
450
450
BOOST_CHECK (!pool.exists (tx2.GetHash ()));
451
451
452
- pool.addUnchecked (tx2. GetHash (), entry.FromTx (tx2));
452
+ pool.addUnchecked (entry.FromTx (tx2));
453
453
CMutableTransaction tx3 = CMutableTransaction ();
454
454
tx3.vin .resize (1 );
455
455
tx3.vin [0 ].prevout = COutPoint (tx2.GetHash (), 0 );
456
456
tx3.vin [0 ].scriptSig = CScript () << OP_2;
457
457
tx3.vout .resize (1 );
458
458
tx3.vout [0 ].scriptPubKey = CScript () << OP_3 << OP_EQUAL;
459
459
tx3.vout [0 ].nValue = 10 * COIN;
460
- pool.addUnchecked (tx3. GetHash (), entry.Fee (20000LL ).FromTx (tx3));
460
+ pool.addUnchecked (entry.Fee (20000LL ).FromTx (tx3));
461
461
462
462
pool.TrimToSize (pool.DynamicMemoryUsage () * 3 / 4 ); // tx3 should pay for tx2 (CPFP)
463
463
BOOST_CHECK (!pool.exists (tx1.GetHash ()));
@@ -520,10 +520,10 @@ BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest)
520
520
tx7.vout [1 ].scriptPubKey = CScript () << OP_7 << OP_EQUAL;
521
521
tx7.vout [1 ].nValue = 10 * COIN;
522
522
523
- pool.addUnchecked (tx4. GetHash (), entry.Fee (7000LL ).FromTx (tx4));
524
- pool.addUnchecked (tx5. GetHash (), entry.Fee (1000LL ).FromTx (tx5));
525
- pool.addUnchecked (tx6. GetHash (), entry.Fee (1100LL ).FromTx (tx6));
526
- pool.addUnchecked (tx7. GetHash (), entry.Fee (9000LL ).FromTx (tx7));
523
+ pool.addUnchecked (entry.Fee (7000LL ).FromTx (tx4));
524
+ pool.addUnchecked (entry.Fee (1000LL ).FromTx (tx5));
525
+ pool.addUnchecked (entry.Fee (1100LL ).FromTx (tx6));
526
+ pool.addUnchecked (entry.Fee (9000LL ).FromTx (tx7));
527
527
528
528
// we only require this to remove, at max, 2 txn, because it's not clear what we're really optimizing for aside from that
529
529
pool.TrimToSize (pool.DynamicMemoryUsage () - 1 );
@@ -532,17 +532,17 @@ BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest)
532
532
BOOST_CHECK (!pool.exists (tx7.GetHash ()));
533
533
534
534
if (!pool.exists (tx5.GetHash ()))
535
- pool.addUnchecked (tx5. GetHash (), entry.Fee (1000LL ).FromTx (tx5));
536
- pool.addUnchecked (tx7. GetHash (), entry.Fee (9000LL ).FromTx (tx7));
535
+ pool.addUnchecked (entry.Fee (1000LL ).FromTx (tx5));
536
+ pool.addUnchecked (entry.Fee (9000LL ).FromTx (tx7));
537
537
538
538
pool.TrimToSize (pool.DynamicMemoryUsage () / 2 ); // should maximize mempool size by only removing 5/7
539
539
BOOST_CHECK (pool.exists (tx4.GetHash ()));
540
540
BOOST_CHECK (!pool.exists (tx5.GetHash ()));
541
541
BOOST_CHECK (pool.exists (tx6.GetHash ()));
542
542
BOOST_CHECK (!pool.exists (tx7.GetHash ()));
543
543
544
- pool.addUnchecked (tx5. GetHash (), entry.Fee (1000LL ).FromTx (tx5));
545
- pool.addUnchecked (tx7. GetHash (), entry.Fee (9000LL ).FromTx (tx7));
544
+ pool.addUnchecked (entry.Fee (1000LL ).FromTx (tx5));
545
+ pool.addUnchecked (entry.Fee (9000LL ).FromTx (tx7));
546
546
547
547
std::vector<CTransactionRef> vtx;
548
548
SetMockTime (42 );
@@ -603,7 +603,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests)
603
603
// [tx1]
604
604
//
605
605
CTransactionRef tx1 = make_tx (/* output_values */ {10 * COIN});
606
- pool.addUnchecked (tx1-> GetHash (), entry.Fee (10000LL ).FromTx (tx1));
606
+ pool.addUnchecked (entry.Fee (10000LL ).FromTx (tx1));
607
607
608
608
// Ancestors / descendants should be 1 / 1 (itself / itself)
609
609
pool.GetTransactionAncestry (tx1->GetHash (), ancestors, descendants);
@@ -615,7 +615,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests)
615
615
// [tx1].0 <- [tx2]
616
616
//
617
617
CTransactionRef tx2 = make_tx (/* output_values */ {495 * CENT, 5 * COIN}, /* inputs */ {tx1});
618
- pool.addUnchecked (tx2-> GetHash (), entry.Fee (10000LL ).FromTx (tx2));
618
+ pool.addUnchecked (entry.Fee (10000LL ).FromTx (tx2));
619
619
620
620
// Ancestors / descendants should be:
621
621
// transaction ancestors descendants
@@ -634,7 +634,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests)
634
634
// [tx1].0 <- [tx2].0 <- [tx3]
635
635
//
636
636
CTransactionRef tx3 = make_tx (/* output_values */ {290 * CENT, 200 * CENT}, /* inputs */ {tx2});
637
- pool.addUnchecked (tx3-> GetHash (), entry.Fee (10000LL ).FromTx (tx3));
637
+ pool.addUnchecked (entry.Fee (10000LL ).FromTx (tx3));
638
638
639
639
// Ancestors / descendants should be:
640
640
// transaction ancestors descendants
@@ -659,7 +659,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests)
659
659
// \---1 <- [tx4]
660
660
//
661
661
CTransactionRef tx4 = make_tx (/* output_values */ {290 * CENT, 250 * CENT}, /* inputs */ {tx2}, /* input_indices */ {1 });
662
- pool.addUnchecked (tx4-> GetHash (), entry.Fee (10000LL ).FromTx (tx4));
662
+ pool.addUnchecked (entry.Fee (10000LL ).FromTx (tx4));
663
663
664
664
// Ancestors / descendants should be:
665
665
// transaction ancestors descendants
@@ -696,13 +696,13 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests)
696
696
CTransactionRef& tyi = *ty[i];
697
697
tyi = make_tx (/* output_values */ {v}, /* inputs */ i > 0 ? std::vector<CTransactionRef>{*ty[i - 1 ]} : std::vector<CTransactionRef>{});
698
698
v -= 50 * CENT;
699
- pool.addUnchecked (tyi-> GetHash (), entry.Fee (10000LL ).FromTx (tyi));
699
+ pool.addUnchecked (entry.Fee (10000LL ).FromTx (tyi));
700
700
pool.GetTransactionAncestry (tyi->GetHash (), ancestors, descendants);
701
701
BOOST_CHECK_EQUAL (ancestors, i+1 );
702
702
BOOST_CHECK_EQUAL (descendants, i+1 );
703
703
}
704
704
CTransactionRef ty6 = make_tx (/* output_values */ {5 * COIN}, /* inputs */ {tx3, ty5});
705
- pool.addUnchecked (ty6-> GetHash (), entry.Fee (10000LL ).FromTx (ty6));
705
+ pool.addUnchecked (entry.Fee (10000LL ).FromTx (ty6));
706
706
707
707
// Ancestors / descendants should be:
708
708
// transaction ancestors descendants
0 commit comments