You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
LogPrint(BCLog::ADDRMAN, "Moving %s to tried\n", addr.ToString());
236
+
// which tried bucket to move the entry to
237
+
int tried_bucket = info.GetTriedBucket(nKey);
238
+
int tried_bucket_pos = info.GetBucketPosition(nKey, false, tried_bucket);
239
+
240
+
// Will moving this address into tried evict another entry?
241
+
if (test_before_evict && (vvTried[tried_bucket][tried_bucket_pos] != -1)) {
242
+
LogPrint(BCLog::ADDRMAN, "addrman", "Collision inserting element into tried table, moving %s to m_tried_collisions=%d\n", addr.ToString(), m_tried_collisions.size());
243
+
if (m_tried_collisions.size() < ADDRMAN_SET_TRIED_COLLISION_SIZE) {
244
+
m_tried_collisions.insert(nId);
245
+
}
246
+
} else {
247
+
LogPrint(BCLog::ADDRMAN, "Moving %s to tried\n", addr.ToString());
0 commit comments