mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Improve addrman Select() performance when buckets are nearly empty
This commit is contained in:
parent
da9beb288d
commit
c33c11ebac
@ -341,8 +341,10 @@ CAddrInfo CAddrMan::Select_()
|
|||||||
while (1) {
|
while (1) {
|
||||||
int nKBucket = GetRandInt(ADDRMAN_TRIED_BUCKET_COUNT);
|
int nKBucket = GetRandInt(ADDRMAN_TRIED_BUCKET_COUNT);
|
||||||
int nKBucketPos = GetRandInt(ADDRMAN_BUCKET_SIZE);
|
int nKBucketPos = GetRandInt(ADDRMAN_BUCKET_SIZE);
|
||||||
if (vvTried[nKBucket][nKBucketPos] == -1)
|
while (vvTried[nKBucket][nKBucketPos] == -1) {
|
||||||
continue;
|
nKBucket = (nKBucket + insecure_rand()) % ADDRMAN_TRIED_BUCKET_COUNT;
|
||||||
|
nKBucketPos = (nKBucketPos + insecure_rand()) % ADDRMAN_BUCKET_SIZE;
|
||||||
|
}
|
||||||
int nId = vvTried[nKBucket][nKBucketPos];
|
int nId = vvTried[nKBucket][nKBucketPos];
|
||||||
assert(mapInfo.count(nId) == 1);
|
assert(mapInfo.count(nId) == 1);
|
||||||
CAddrInfo& info = mapInfo[nId];
|
CAddrInfo& info = mapInfo[nId];
|
||||||
@ -356,8 +358,10 @@ CAddrInfo CAddrMan::Select_()
|
|||||||
while (1) {
|
while (1) {
|
||||||
int nUBucket = GetRandInt(ADDRMAN_NEW_BUCKET_COUNT);
|
int nUBucket = GetRandInt(ADDRMAN_NEW_BUCKET_COUNT);
|
||||||
int nUBucketPos = GetRandInt(ADDRMAN_BUCKET_SIZE);
|
int nUBucketPos = GetRandInt(ADDRMAN_BUCKET_SIZE);
|
||||||
if (vvNew[nUBucket][nUBucketPos] == -1)
|
while (vvNew[nUBucket][nUBucketPos] == -1) {
|
||||||
continue;
|
nUBucket = (nUBucket + insecure_rand()) % ADDRMAN_NEW_BUCKET_COUNT;
|
||||||
|
nUBucketPos = (nUBucketPos + insecure_rand()) % ADDRMAN_BUCKET_SIZE;
|
||||||
|
}
|
||||||
int nId = vvNew[nUBucket][nUBucketPos];
|
int nId = vvNew[nUBucket][nUBucketPos];
|
||||||
assert(mapInfo.count(nId) == 1);
|
assert(mapInfo.count(nId) == 1);
|
||||||
CAddrInfo& info = mapInfo[nId];
|
CAddrInfo& info = mapInfo[nId];
|
||||||
|
Loading…
Reference in New Issue
Block a user