| 140 | } |
| 141 | |
| 142 | void CAddrMan::MakeTried(CAddrInfo& info, int nId) |
| 143 | { |
| 144 | // remove the entry from all new buckets |
| 145 | for (int bucket = 0; bucket < ADDRMAN_NEW_BUCKET_COUNT; bucket++) { |
| 146 | int pos = info.GetBucketPosition(nKey, true, bucket); |
| 147 | if (vvNew[bucket][pos] == nId) { |
| 148 | vvNew[bucket][pos] = -1; |
| 149 | info.nRefCount--; |
| 150 | } |
| 151 | } |
| 152 | nNew--; |
| 153 | |
| 154 | assert(info.nRefCount == 0); |
| 155 | |
| 156 | // which tried bucket to move the entry to |
| 157 | int nKBucket = info.GetTriedBucket(nKey); |
| 158 | int nKBucketPos = info.GetBucketPosition(nKey, false, nKBucket); |
| 159 | |
| 160 | // first make space to add it (the existing tried entry there is moved to new, deleting whatever is there). |
| 161 | if (vvTried[nKBucket][nKBucketPos] != -1) { |
| 162 | // find an item to evict |
| 163 | int nIdEvict = vvTried[nKBucket][nKBucketPos]; |
| 164 | assert(mapInfo.count(nIdEvict) == 1); |
| 165 | CAddrInfo& infoOld = mapInfo[nIdEvict]; |
| 166 | |
| 167 | // Remove the to-be-evicted item from the tried set. |
| 168 | infoOld.fInTried = false; |
| 169 | vvTried[nKBucket][nKBucketPos] = -1; |
| 170 | nTried--; |
| 171 | |
| 172 | // find which new bucket it belongs to |
| 173 | int nUBucket = infoOld.GetNewBucket(nKey); |
| 174 | int nUBucketPos = infoOld.GetBucketPosition(nKey, true, nUBucket); |
| 175 | ClearNew(nUBucket, nUBucketPos); |
| 176 | assert(vvNew[nUBucket][nUBucketPos] == -1); |
| 177 | |
| 178 | // Enter it into the new set again. |
| 179 | infoOld.nRefCount = 1; |
| 180 | vvNew[nUBucket][nUBucketPos] = nIdEvict; |
| 181 | nNew++; |
| 182 | } |
| 183 | assert(vvTried[nKBucket][nKBucketPos] == -1); |
| 184 | |
| 185 | vvTried[nKBucket][nKBucketPos] = nId; |
| 186 | nTried++; |
| 187 | info.fInTried = true; |
| 188 | } |
| 189 | |
| 190 | void CAddrMan::Good_(const CService& addr, bool test_before_evict, int64_t nTime) |
| 191 | { |
nothing calls this directly
no test coverage detected