mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
Creates unittests for addrman, makes addrman testable.
Adds several unittests for addrman to verify it works as expected. Makes small modifications to addrman to allow deterministic and targeted tests.
This commit is contained in:
@@ -329,13 +329,17 @@ void CAddrMan::Attempt_(const CService& addr, int64_t nTime)
|
||||
info.nAttempts++;
|
||||
}
|
||||
|
||||
CAddrInfo CAddrMan::Select_()
|
||||
CAddrInfo CAddrMan::Select_(bool newOnly)
|
||||
{
|
||||
if (size() == 0)
|
||||
return CAddrInfo();
|
||||
|
||||
if (newOnly && nNew == 0)
|
||||
return CAddrInfo();
|
||||
|
||||
// Use a 50% chance for choosing between tried and new table entries.
|
||||
if (nTried > 0 && (nNew == 0 || GetRandInt(2) == 0)) {
|
||||
if (!newOnly &&
|
||||
(nTried > 0 && (nNew == 0 || GetRandInt(2) == 0))) {
|
||||
// use a tried node
|
||||
double fChanceFactor = 1.0;
|
||||
while (1) {
|
||||
|
||||
Reference in New Issue
Block a user