Skip to content

Commit acf656d

Browse files
committed
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.
1 parent eb2e113 commit acf656d

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

src/test/fuzz/addrman.cpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -96,31 +96,12 @@ class CAddrManDeterministic : public CAddrMan
9696
for (size_t j = 0; j < num_addresses; ++j) {
9797
const auto addr = CAddress{CService{RandAddr(), 8333}, NODE_NETWORK};
9898
const auto time_penalty = insecure_rand.randrange(100000001);
99-
#if 1
100-
// 2.83 sec to fill.
101-
if (n > 0 && mapInfo.size() % n == 0 && mapAddr.find(addr) == mapAddr.end()) {
102-
// Add to the "tried" table (if the bucket slot is free).
103-
const CAddrInfo dummy{addr, source};
104-
const int bucket = dummy.GetTriedBucket(nKey, m_asmap);
105-
const int bucket_pos = dummy.GetBucketPosition(nKey, false, bucket);
106-
if (vvTried[bucket][bucket_pos] == -1) {
107-
int id;
108-
CAddrInfo* addr_info = Create(addr, source, &id);
109-
vvTried[bucket][bucket_pos] = id;
110-
addr_info->fInTried = true;
111-
++nTried;
112-
}
113-
} else {
114-
// Add to the "new" table.
115-
Add_(addr, source, time_penalty);
116-
}
117-
#else
118-
// 261.91 sec to fill.
11999
Add_(addr, source, time_penalty);
100+
120101
if (n > 0 && mapInfo.size() % n == 0) {
121102
Good_(addr, false, GetTime());
122103
}
123-
#endif
104+
124105
// Add 10% of the addresses from more than one source.
125106
if (insecure_rand.randrange(10) == 0 && prev_source.IsValid()) {
126107
Add_(addr, prev_source, time_penalty);

0 commit comments

Comments
 (0)