-
Notifications
You must be signed in to change notification settings - Fork 37.7k
refactor: Remove unused methods CBloomFilter::reset()/clear() #18670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Remove unused methods CBloomFilter::reset()/clear() #18670
Conversation
Hint for reviewers: there are seemingly bitcoin/src/net_processing.cpp Line 3164 in 661e8df
but those refer to std::unique_ptr::reset() , not to CBloomFilter::reset() !
|
ACK. Please also remove diff --git a/src/test/bloom_tests.cpp b/src/test/bloom_tests.cpp
index 4a7ad9b38b..bcf2e8ccff 100644
--- a/src/test/bloom_tests.cpp
+++ b/src/test/bloom_tests.cpp
@@ -27,6 +27,7 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize)
{
CBloomFilter filter(3, 0.01, 0, BLOOM_UPDATE_ALL);
+ BOOST_CHECK_MESSAGE( !filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter should be empty!");
filter.insert(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8"));
BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter doesn't contain just-inserted object!");
// One bit different in first byte
@@ -50,8 +51,6 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize)
BOOST_CHECK_EQUAL_COLLECTIONS(stream.begin(), stream.end(), expected.begin(), expected.end());
BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter doesn't contain just-inserted object!");
- filter.clear();
- BOOST_CHECK_MESSAGE( !filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter should be empty!");
}
BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize_with_tweak) |
cfbc5a5
to
9b95bdc
Compare
Updated commit, PR title and description to reflect the change of also removing |
ACK 9b95bdc |
1 similar comment
ACK 9b95bdc |
ACK 9b95bdc |
|
Co-authored-by: MarcoFalke <falke.marco@gmail.com>
9b95bdc
to
69ffddc
Compare
Force-pushed commit, now also removes the two methods from the bloom filter fuzz test. |
re-ACK 69ffddc |
ACK 69ffddc, code review, compiled a fuzz build and started the bloom_filter fuzz test as a sanity check. |
ACK 69ffddc. |
Post-merge ACK 69ffddc Thanks for removing If you want to look at adding tests for unused functions (or remove unused functions that are unlikely to be used in the near future) then this list might be helpful:
But as said: please note that at least some of these have been added recently and might be intentionally unused for the time being but has concrete plans for near future use in an open PR ( Edit: List is not entirely correct. Example: |
@practicalswift: Thanks for your valuable input, this wanders directly onto my Bitcoin Core TODO list. For some functions, e.g. the constructors of CBloomFilter() and BlockFilter() it can be quite confusing to the reader that they are never actually used anywhere in bitcoind, only for test purposes. For those cases it would make sense to add a comment like "only for testing". |
Summary: Co-authored-by: MarcoFalke <falke.marco@gmail.com> > The method CBloomFilter::reset() was introduced by commit d2d7ee0 in 2015, but was never ever used, as far as I could find. As discovered by MarcoFalke, the method clear() is also unused outside of unit tests and is hence also removed. This is a backport of Core [[bitcoin/bitcoin#18670 | PR18670]] Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D8937
Backport bloom filter improvements Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#7113 - bitcoin/bitcoin#7818 - Only the second commit (to resolve conflicts). - bitcoin/bitcoin#7934 - bitcoin/bitcoin#8655 - Partial backport to help resolve conflicts. - bitcoin/bitcoin#9060 - bitcoin/bitcoin#9223 - bitcoin/bitcoin#9644 - Partial backport to help resolve conflicts. - bitcoin/bitcoin#9916 - bitcoin/bitcoin#9750 - bitcoin/bitcoin#13176 - bitcoin/bitcoin#13948 - bitcoin/bitcoin#16073 - bitcoin/bitcoin#18670 - bitcoin/bitcoin#18806 - Reveals upstream's covert fix for CVE-2013-5700. - bitcoin/bitcoin#19968
Backport bloom filter improvements Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#7113 - bitcoin/bitcoin#7818 - Only the second commit (to resolve conflicts). - bitcoin/bitcoin#7934 - bitcoin/bitcoin#8655 - Partial backport to help resolve conflicts. - bitcoin/bitcoin#9060 - bitcoin/bitcoin#9223 - bitcoin/bitcoin#9644 - Partial backport to help resolve conflicts. - bitcoin/bitcoin#9916 - bitcoin/bitcoin#9750 - bitcoin/bitcoin#13176 - bitcoin/bitcoin#13948 - bitcoin/bitcoin#16073 - bitcoin/bitcoin#18670 - bitcoin/bitcoin#18806 - Reveals upstream's covert fix for CVE-2013-5700. - bitcoin/bitcoin#19968
The method
CBloomFilter::reset()
was introduced by commit d2d7ee0 in 2015, but was never ever used, as far as I could find. As discovered by MarcoFalke, the methodclear()
is also unused outside of unit tests and is hence also removed.