mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02: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:
parent
bf3353de90
commit
e68172ed9f
4 changed files with 319 additions and 19 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue