mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-19 21:31:33 +02:00
Add missing const to CAddrMan::Check_()
Also: Always compile the function signature to avoid similar issues in the future.
This commit is contained in:
parent
d67330d112
commit
ee458d84fc
@ -431,9 +431,9 @@ CAddrInfo CAddrMan::Select_(bool newOnly) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_ADDRMAN
|
int CAddrMan::Check_() const
|
||||||
int CAddrMan::Check_()
|
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_ADDRMAN
|
||||||
AssertLockHeld(cs);
|
AssertLockHeld(cs);
|
||||||
|
|
||||||
std::unordered_set<int> setTried;
|
std::unordered_set<int> setTried;
|
||||||
@ -458,8 +458,10 @@ int CAddrMan::Check_()
|
|||||||
return -4;
|
return -4;
|
||||||
mapNew[n] = info.nRefCount;
|
mapNew[n] = info.nRefCount;
|
||||||
}
|
}
|
||||||
if (mapAddr[info] != n)
|
const auto it{mapAddr.find(info)};
|
||||||
|
if (it == mapAddr.end() || it->second != n) {
|
||||||
return -5;
|
return -5;
|
||||||
|
}
|
||||||
if (info.nRandomPos < 0 || (size_t)info.nRandomPos >= vRandom.size() || vRandom[info.nRandomPos] != n)
|
if (info.nRandomPos < 0 || (size_t)info.nRandomPos >= vRandom.size() || vRandom[info.nRandomPos] != n)
|
||||||
return -14;
|
return -14;
|
||||||
if (info.nLastTry < 0)
|
if (info.nLastTry < 0)
|
||||||
@ -478,10 +480,13 @@ int CAddrMan::Check_()
|
|||||||
if (vvTried[n][i] != -1) {
|
if (vvTried[n][i] != -1) {
|
||||||
if (!setTried.count(vvTried[n][i]))
|
if (!setTried.count(vvTried[n][i]))
|
||||||
return -11;
|
return -11;
|
||||||
if (mapInfo[vvTried[n][i]].GetTriedBucket(nKey, m_asmap) != n)
|
const auto it{mapInfo.find(vvTried[n][i])};
|
||||||
|
if (it == mapInfo.end() || it->second.GetTriedBucket(nKey, m_asmap) != n) {
|
||||||
return -17;
|
return -17;
|
||||||
if (mapInfo[vvTried[n][i]].GetBucketPosition(nKey, false, n) != i)
|
}
|
||||||
|
if (it->second.GetBucketPosition(nKey, false, n) != i) {
|
||||||
return -18;
|
return -18;
|
||||||
|
}
|
||||||
setTried.erase(vvTried[n][i]);
|
setTried.erase(vvTried[n][i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -492,8 +497,10 @@ int CAddrMan::Check_()
|
|||||||
if (vvNew[n][i] != -1) {
|
if (vvNew[n][i] != -1) {
|
||||||
if (!mapNew.count(vvNew[n][i]))
|
if (!mapNew.count(vvNew[n][i]))
|
||||||
return -12;
|
return -12;
|
||||||
if (mapInfo[vvNew[n][i]].GetBucketPosition(nKey, true, n) != i)
|
const auto it{mapInfo.find(vvNew[n][i])};
|
||||||
|
if (it == mapInfo.end() || it->second.GetBucketPosition(nKey, true, n) != i) {
|
||||||
return -19;
|
return -19;
|
||||||
|
}
|
||||||
if (--mapNew[vvNew[n][i]] == 0)
|
if (--mapNew[vvNew[n][i]] == 0)
|
||||||
mapNew.erase(vvNew[n][i]);
|
mapNew.erase(vvNew[n][i]);
|
||||||
}
|
}
|
||||||
@ -507,9 +514,9 @@ int CAddrMan::Check_()
|
|||||||
if (nKey.IsNull())
|
if (nKey.IsNull())
|
||||||
return -16;
|
return -16;
|
||||||
|
|
||||||
|
#endif // DEBUG_ADDRMAN
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void CAddrMan::GetAddr_(std::vector<CAddress>& vAddr, size_t max_addresses, size_t max_pct, std::optional<Network> network) const
|
void CAddrMan::GetAddr_(std::vector<CAddress>& vAddr, size_t max_addresses, size_t max_pct, std::optional<Network> network) const
|
||||||
{
|
{
|
||||||
|
@ -738,19 +738,15 @@ private:
|
|||||||
void Check() const
|
void Check() const
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(cs)
|
EXCLUSIVE_LOCKS_REQUIRED(cs)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_ADDRMAN
|
|
||||||
AssertLockHeld(cs);
|
AssertLockHeld(cs);
|
||||||
const int err = Check_();
|
const int err = Check_();
|
||||||
if (err) {
|
if (err) {
|
||||||
LogPrintf("ADDRMAN CONSISTENCY CHECK FAILED!!! err=%i\n", err);
|
LogPrintf("ADDRMAN CONSISTENCY CHECK FAILED!!! err=%i\n", err);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_ADDRMAN
|
|
||||||
//! Perform consistency check. Returns an error code or zero.
|
//! Perform consistency check. Returns an error code or zero.
|
||||||
int Check_() const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
int Check_() const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all or many randomly selected addresses, optionally by network.
|
* Return all or many randomly selected addresses, optionally by network.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user