aboutsummaryrefslogtreecommitdiff
path: root/src/test/net_peer_eviction_tests.cpp
AgeCommit message (Collapse)Author
2021-03-19Add unit test coverage for our onion peer eviction protectionJon Atack
2021-03-19Protect onion+localhost peers in ProtectEvictionCandidatesByRatio()Jon Atack
Now that we have a reliable way to detect inbound onion peers, this commit updates our existing eviction protection of 1/4 localhost peers to instead protect up to 1/4 onion peers (connected via our tor control service), sorted by longest uptime. Any remaining slots of the 1/4 are then allocated to protect localhost peers, or 2 localhost peers if no slots remain and 2 or more onion peers are protected, sorted by longest uptime. The goal is to avoid penalizing onion peers, due to their higher min ping times relative to IPv4 and IPv6 peers, and improve our diversity of peer connections. Thank you to Gregory Maxwell, Suhas Daftuar, Vasil Dimov and Pieter Wuille for valuable review feedback that shaped the direction.
2021-03-19Add m_inbound_onion to AttemptToEvictConnection()Jon Atack
and an `m_is_onion` struct member to NodeEvictionCandidate and tests. We'll use these in the peer eviction logic to protect inbound onion peers in addition to the existing protection of localhost peers.
2021-03-19Add unit tests for ProtectEvictionCandidatesByRatio()Jon Atack
Thank you to Vasil Dimov (vasild) for the suggestion to use std::unordered_set rather than std::vector for the IsProtected() peer id arguments.
2021-03-19Use std::unordered_set instead of std::vector in IsEvicted()Jon Atack
An unordered set can tell if an element is present in ~O(1) time (constant on average, worst case linear to the size of the container), which speeds up and simplifies the lookup in IsEvicted(). Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
2021-03-19Move peer eviction tests to a separate test fileJon Atack
out of net_tests, because the eviction tests: - are a different domain of test coverage, with different dependencies - run more slowly than the net tests - will be growing in size, in this PR branch and in the future, as eviction test coverage is improved