Commit cd72033
MarcoFalke
Merge #20222: refactor: CTxMempool constructor clean up
f15e780 refactor: Clean up CTxMemPool initializer list (Elle Mouton)
e331069 refactor: Make CTxMemPool::m_check_ratio a const and a constructor argument (Elle Mouton)
9d4b4b2 refactor: Avoid double to int cast for nCheckFrequency (Elle Mouton)
Pull request description:
This PR cleans up the CTxMemPool interface by including the ratio used to determine when a mempool sanity check should run in the constructor of CTxMempool instead of using nCheckFrequency which required a cast from a double to a uint32_t. Since nCheckFrequency (now called m_check_ratio) is set in the constructor and only every read from there after, it can be turned into a const and no longer needs to be guarded by the 'cs' lock.
Since nCheckFrequency/m_check_ratio no longer needs to lock the 'cs' mutux, mutex lock line in the "CTxMempool::check" function can be moved below where the m_check_ratio variable is checked. Since the variable is 0 by default (meaning that "CTxMempool::check" will most likely not run its logic) this saves us from unnecessarily grabbing the lock.
ACKs for top commit:
jnewbery:
utACK f15e780
MarcoFalke:
ACK f15e780 👘
glozow:
utACK bitcoin/bitcoin@f15e780
theStack:
Code Review ACK f15e780
Tree-SHA512: d83f3b5311ca128847b621e5e999c7e1bf0f4e6261d4cc090fb13e229a0f7eecd66ad997f654f50a838baf708d1515740aa3bffc244909a001d01fd5ae398b68File tree
4 files changed
+20
-30
lines changed- src
- test/util
4 files changed
+20
-30
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1389 | 1389 | | |
1390 | 1390 | | |
1391 | 1391 | | |
1392 | | - | |
1393 | | - | |
1394 | 1392 | | |
1395 | | - | |
1396 | | - | |
1397 | | - | |
1398 | | - | |
1399 | | - | |
1400 | | - | |
1401 | | - | |
| 1393 | + | |
| 1394 | + | |
1402 | 1395 | | |
1403 | 1396 | | |
1404 | 1397 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
145 | | - | |
| 144 | + | |
146 | 145 | | |
147 | 146 | | |
148 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
334 | | - | |
335 | | - | |
| 334 | + | |
| 335 | + | |
336 | 336 | | |
337 | 337 | | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | 338 | | |
344 | 339 | | |
345 | 340 | | |
| |||
523 | 518 | | |
524 | 519 | | |
525 | 520 | | |
526 | | - | |
| 521 | + | |
527 | 522 | | |
528 | 523 | | |
529 | 524 | | |
| |||
619 | 614 | | |
620 | 615 | | |
621 | 616 | | |
622 | | - | |
623 | | - | |
624 | | - | |
| 617 | + | |
625 | 618 | | |
626 | | - | |
627 | | - | |
| 619 | + | |
628 | 620 | | |
| 621 | + | |
629 | 622 | | |
630 | 623 | | |
631 | 624 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
488 | 488 | | |
489 | 489 | | |
490 | 490 | | |
491 | | - | |
492 | | - | |
| 491 | + | |
| 492 | + | |
493 | 493 | | |
494 | 494 | | |
495 | 495 | | |
| |||
498 | 498 | | |
499 | 499 | | |
500 | 500 | | |
501 | | - | |
502 | | - | |
| 501 | + | |
| 502 | + | |
503 | 503 | | |
504 | 504 | | |
505 | 505 | | |
| |||
601 | 601 | | |
602 | 602 | | |
603 | 603 | | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
604 | 610 | | |
605 | | - | |
| 611 | + | |
606 | 612 | | |
607 | 613 | | |
608 | 614 | | |
| |||
611 | 617 | | |
612 | 618 | | |
613 | 619 | | |
614 | | - | |
615 | 620 | | |
616 | 621 | | |
617 | 622 | | |
| |||
0 commit comments