mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 07:09:15 +01:00
Add test-before-evict discipline to addrman
Changes addrman to use the test-before-evict discipline in which an address is to be evicted from the tried table is first tested and if it is still online it is not evicted. Adds tests to provide test coverage for this change. This change was suggested as Countermeasure 3 in Eclipse Attacks on Bitcoin’s Peer-to-Peer Network, Ethan Heilman, Alison Kendler, Aviv Zohar, Sharon Goldberg. ePrint Archive Report 2015/263. March 2015.
This commit is contained in:
@@ -1824,11 +1824,18 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
|
||||
}
|
||||
}
|
||||
|
||||
addrman.ResolveCollisions();
|
||||
|
||||
int64_t nANow = GetAdjustedTime();
|
||||
int nTries = 0;
|
||||
while (!interruptNet)
|
||||
{
|
||||
CAddrInfo addr = addrman.Select(fFeeler);
|
||||
CAddrInfo addr = addrman.SelectTriedCollision();
|
||||
|
||||
// SelectTriedCollision returns an invalid address if it is empty.
|
||||
if (!fFeeler || !addr.IsValid()) {
|
||||
addr = addrman.Select(fFeeler);
|
||||
}
|
||||
|
||||
// if we selected an invalid address, restart
|
||||
if (!addr.IsValid() || setConnected.count(addr.GetGroup()) || IsLocal(addr))
|
||||
|
||||
Reference in New Issue
Block a user