aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Zumsande <mzumsande@gmail.com>2021-09-10 02:23:16 +0200
committerMartin Zumsande <mzumsande@gmail.com>2021-09-16 00:50:48 +0200
commitacf656d540a82e6fc30421590305cfe295eabbb5 (patch)
treed8bd4f4aff5f380c5b62e63ed5c53396f95eea99 /src
parenteb2e113df13c7b1ede279878f5cbad877af49f8e (diff)
downloadbitcoin-acf656d540a82e6fc30421590305cfe295eabbb5.tar.xz
fuzz: Use public interface to fill addrman tried tables
After the performance improvement for Good(), the direct method is only 2x faster as opposed to 60x before.
Diffstat (limited to 'src')
-rw-r--r--src/test/fuzz/addrman.cpp23
1 files changed, 2 insertions, 21 deletions
diff --git a/src/test/fuzz/addrman.cpp b/src/test/fuzz/addrman.cpp
index fdbfb3b93b..1781420f4f 100644
--- a/src/test/fuzz/addrman.cpp
+++ b/src/test/fuzz/addrman.cpp
@@ -96,31 +96,12 @@ public:
for (size_t j = 0; j < num_addresses; ++j) {
const auto addr = CAddress{CService{RandAddr(), 8333}, NODE_NETWORK};
const auto time_penalty = insecure_rand.randrange(100000001);
-#if 1
- // 2.83 sec to fill.
- if (n > 0 && mapInfo.size() % n == 0 && mapAddr.find(addr) == mapAddr.end()) {
- // Add to the "tried" table (if the bucket slot is free).
- const CAddrInfo dummy{addr, source};
- const int bucket = dummy.GetTriedBucket(nKey, m_asmap);
- const int bucket_pos = dummy.GetBucketPosition(nKey, false, bucket);
- if (vvTried[bucket][bucket_pos] == -1) {
- int id;
- CAddrInfo* addr_info = Create(addr, source, &id);
- vvTried[bucket][bucket_pos] = id;
- addr_info->fInTried = true;
- ++nTried;
- }
- } else {
- // Add to the "new" table.
- Add_(addr, source, time_penalty);
- }
-#else
- // 261.91 sec to fill.
Add_(addr, source, time_penalty);
+
if (n > 0 && mapInfo.size() % n == 0) {
Good_(addr, false, GetTime());
}
-#endif
+
// Add 10% of the addresses from more than one source.
if (insecure_rand.randrange(10) == 0 && prev_source.IsValid()) {
Add_(addr, prev_source, time_penalty);