From 3f44b0ae3d291d8dbfe55e420b3fdc8a88d068e0 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sat, 13 Apr 2013 21:45:36 +0200 Subject: [PATCH] Remove weird 10% inverted selection logic --- db.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/db.cpp b/db.cpp index 98b467d..47b5e28 100644 --- a/db.cpp +++ b/db.cpp @@ -51,16 +51,9 @@ bool CAddrDb::Get_(CService &ip, int &wait) { int rnd = rand() % tot; int ret; if (rnd < unkId.size()) { - if (rnd*10 < unkId.size()) { - // once every 10 attempts, restart with the oldest unknown IP - set::iterator it = unkId.begin(); - ret = *it; - } else { - // 90% of the time try the last learned IP - set::reverse_iterator it = unkId.rbegin(); - ret = *it; - } - unkId.erase(ret); + set::iterator it = unkId.end(); it--; + ret = *it; + unkId.erase(it); } else { ret = ourId.front(); if (time(NULL) - idToInfo[ret].ourLastTry < MIN_RETRY) return false;