MCPcopy Create free account
hub / github.com/LUX-Core/lux / MakeTried

Method MakeTried

src/addrman.cpp:145–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

GetBucketPositionMethod · 0.80
GetTriedBucketMethod · 0.80
countMethod · 0.45
GetNewBucketMethod · 0.45

Tested by

no test coverage detected