Remove weird 10% inverted selection logic
This commit is contained in:
parent
5df66a2212
commit
3f44b0ae3d
1 changed files with 3 additions and 10 deletions
13
db.cpp
13
db.cpp
|
@ -51,16 +51,9 @@ bool CAddrDb::Get_(CService &ip, int &wait) {
|
||||||
int rnd = rand() % tot;
|
int rnd = rand() % tot;
|
||||||
int ret;
|
int ret;
|
||||||
if (rnd < unkId.size()) {
|
if (rnd < unkId.size()) {
|
||||||
if (rnd*10 < unkId.size()) {
|
set<int>::iterator it = unkId.end(); it--;
|
||||||
// once every 10 attempts, restart with the oldest unknown IP
|
ret = *it;
|
||||||
set<int>::iterator it = unkId.begin();
|
unkId.erase(it);
|
||||||
ret = *it;
|
|
||||||
} else {
|
|
||||||
// 90% of the time try the last learned IP
|
|
||||||
set<int>::reverse_iterator it = unkId.rbegin();
|
|
||||||
ret = *it;
|
|
||||||
}
|
|
||||||
unkId.erase(ret);
|
|
||||||
} else {
|
} else {
|
||||||
ret = ourId.front();
|
ret = ourId.front();
|
||||||
if (time(NULL) - idToInfo[ret].ourLastTry < MIN_RETRY) return false;
|
if (time(NULL) - idToInfo[ret].ourLastTry < MIN_RETRY) return false;
|
||||||
|
|
Loading…
Reference in a new issue