diff options
| author | Wladimir J. van der Laan <[email protected]> | 2015-10-07 14:43:38 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2015-10-07 14:59:58 +0200 |
| commit | d479311dba25d6a697a0c5bebbb1e913a0121b9f (patch) | |
| tree | 0b68ebc3223acb130a375d200ccdac7b6205ecf0 /src/addrman.cpp | |
| parent | Merge pull request #6769 (diff) | |
| parent | Creates unittests for addrman, makes addrman testable. (diff) | |
| download | discoin-d479311dba25d6a697a0c5bebbb1e913a0121b9f.tar.xz discoin-d479311dba25d6a697a0c5bebbb1e913a0121b9f.zip | |
Merge pull request #6720
1534d9a 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. (EthanHeilman)
Diffstat (limited to 'src/addrman.cpp')
| -rw-r--r-- | src/addrman.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/addrman.cpp b/src/addrman.cpp index ff1f7e918..078b9e168 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -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) { |