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