mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
Refactor: Turn the internal addrman check helper into a forced check
This commit is contained in:
parent
fae5c633dc
commit
fa298971e6
2 changed files with 10 additions and 9 deletions
|
@ -747,21 +747,21 @@ void CAddrMan::Check() const
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs);
|
AssertLockHeld(cs);
|
||||||
|
|
||||||
const int err = Check_();
|
// Run consistency checks 1 in m_consistency_check_ratio times if enabled
|
||||||
|
if (m_consistency_check_ratio == 0) return;
|
||||||
|
if (insecure_rand.randrange(m_consistency_check_ratio) >= 1) return;
|
||||||
|
|
||||||
|
const int err{ForceCheckAddrman()};
|
||||||
if (err) {
|
if (err) {
|
||||||
LogPrintf("ADDRMAN CONSISTENCY CHECK FAILED!!! err=%i\n", err);
|
LogPrintf("ADDRMAN CONSISTENCY CHECK FAILED!!! err=%i\n", err);
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int CAddrMan::Check_() const
|
int CAddrMan::ForceCheckAddrman() const
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs);
|
AssertLockHeld(cs);
|
||||||
|
|
||||||
// Run consistency checks 1 in m_consistency_check_ratio times if enabled
|
|
||||||
if (m_consistency_check_ratio == 0) return 0;
|
|
||||||
if (insecure_rand.randrange(m_consistency_check_ratio) >= 1) return 0;
|
|
||||||
|
|
||||||
LogPrint(BCLog::ADDRMAN, "Addrman checks started: new %i, tried %i, total %u\n", nNew, nTried, vRandom.size());
|
LogPrint(BCLog::ADDRMAN, "Addrman checks started: new %i, tried %i, total %u\n", nNew, nTried, vRandom.size());
|
||||||
|
|
||||||
std::unordered_set<int> setTried;
|
std::unordered_set<int> setTried;
|
||||||
|
|
|
@ -391,11 +391,12 @@ private:
|
||||||
//! Return a random to-be-evicted tried table address.
|
//! Return a random to-be-evicted tried table address.
|
||||||
CAddrInfo SelectTriedCollision_() EXCLUSIVE_LOCKS_REQUIRED(cs);
|
CAddrInfo SelectTriedCollision_() EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||||
|
|
||||||
//! Consistency check
|
//! Consistency check, taking into account m_consistency_check_ratio. Will std::abort if an inconsistency is detected.
|
||||||
void Check() const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
void Check() const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||||
|
|
||||||
//! Perform consistency check. Returns an error code or zero.
|
//! Perform consistency check, regardless of m_consistency_check_ratio.
|
||||||
int Check_() const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
//! @returns an error code or zero.
|
||||||
|
int ForceCheckAddrman() const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all or many randomly selected addresses, optionally by network.
|
* Return all or many randomly selected addresses, optionally by network.
|
||||||
|
|
Loading…
Add table
Reference in a new issue