mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 20:03:34 -03:00
[MOVEONLY] reorder functions in addrman_impl.h and addrman.cpp
Keep the internal {Function}_() functions grouped together. Review with `git diff --color-moved=dimmed-zebra`
This commit is contained in:
parent
2095df7b7b
commit
61ec0539b2
2 changed files with 57 additions and 57 deletions
110
src/addrman.cpp
110
src/addrman.cpp
|
@ -537,61 +537,6 @@ void AddrManImpl::MakeTried(AddrInfo& info, int nId)
|
|||
info.fInTried = true;
|
||||
}
|
||||
|
||||
void AddrManImpl::Good_(const CService& addr, bool test_before_evict, int64_t nTime)
|
||||
{
|
||||
AssertLockHeld(cs);
|
||||
|
||||
int nId;
|
||||
|
||||
nLastGood = nTime;
|
||||
|
||||
AddrInfo* pinfo = Find(addr, &nId);
|
||||
|
||||
// if not found, bail out
|
||||
if (!pinfo)
|
||||
return;
|
||||
|
||||
AddrInfo& info = *pinfo;
|
||||
|
||||
// update info
|
||||
info.nLastSuccess = nTime;
|
||||
info.nLastTry = nTime;
|
||||
info.nAttempts = 0;
|
||||
// nTime is not updated here, to avoid leaking information about
|
||||
// currently-connected peers.
|
||||
|
||||
// if it is already in the tried set, don't do anything else
|
||||
if (info.fInTried)
|
||||
return;
|
||||
|
||||
// if it is not in new, something bad happened
|
||||
if (!Assume(info.nRefCount > 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// which tried bucket to move the entry to
|
||||
int tried_bucket = info.GetTriedBucket(nKey, m_asmap);
|
||||
int tried_bucket_pos = info.GetBucketPosition(nKey, false, tried_bucket);
|
||||
|
||||
// Will moving this address into tried evict another entry?
|
||||
if (test_before_evict && (vvTried[tried_bucket][tried_bucket_pos] != -1)) {
|
||||
if (m_tried_collisions.size() < ADDRMAN_SET_TRIED_COLLISION_SIZE) {
|
||||
m_tried_collisions.insert(nId);
|
||||
}
|
||||
// Output the entry we'd be colliding with, for debugging purposes
|
||||
auto colliding_entry = mapInfo.find(vvTried[tried_bucket][tried_bucket_pos]);
|
||||
LogPrint(BCLog::ADDRMAN, "Collision with %s while attempting to move %s to tried table. Collisions=%d\n",
|
||||
colliding_entry != mapInfo.end() ? colliding_entry->second.ToString() : "",
|
||||
addr.ToString(),
|
||||
m_tried_collisions.size());
|
||||
} else {
|
||||
// move nId to the tried tables
|
||||
MakeTried(info, nId);
|
||||
LogPrint(BCLog::ADDRMAN, "Moved %s mapped to AS%i to tried[%i][%i]\n",
|
||||
addr.ToString(), addr.GetMappedAS(m_asmap), tried_bucket, tried_bucket_pos);
|
||||
}
|
||||
}
|
||||
|
||||
bool AddrManImpl::AddSingle(const CAddress& addr, const CNetAddr& source, int64_t nTimePenalty)
|
||||
{
|
||||
AssertLockHeld(cs);
|
||||
|
@ -667,6 +612,61 @@ bool AddrManImpl::AddSingle(const CAddress& addr, const CNetAddr& source, int64_
|
|||
return fInsert;
|
||||
}
|
||||
|
||||
void AddrManImpl::Good_(const CService& addr, bool test_before_evict, int64_t nTime)
|
||||
{
|
||||
AssertLockHeld(cs);
|
||||
|
||||
int nId;
|
||||
|
||||
nLastGood = nTime;
|
||||
|
||||
AddrInfo* pinfo = Find(addr, &nId);
|
||||
|
||||
// if not found, bail out
|
||||
if (!pinfo)
|
||||
return;
|
||||
|
||||
AddrInfo& info = *pinfo;
|
||||
|
||||
// update info
|
||||
info.nLastSuccess = nTime;
|
||||
info.nLastTry = nTime;
|
||||
info.nAttempts = 0;
|
||||
// nTime is not updated here, to avoid leaking information about
|
||||
// currently-connected peers.
|
||||
|
||||
// if it is already in the tried set, don't do anything else
|
||||
if (info.fInTried)
|
||||
return;
|
||||
|
||||
// if it is not in new, something bad happened
|
||||
if (!Assume(info.nRefCount > 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// which tried bucket to move the entry to
|
||||
int tried_bucket = info.GetTriedBucket(nKey, m_asmap);
|
||||
int tried_bucket_pos = info.GetBucketPosition(nKey, false, tried_bucket);
|
||||
|
||||
// Will moving this address into tried evict another entry?
|
||||
if (test_before_evict && (vvTried[tried_bucket][tried_bucket_pos] != -1)) {
|
||||
if (m_tried_collisions.size() < ADDRMAN_SET_TRIED_COLLISION_SIZE) {
|
||||
m_tried_collisions.insert(nId);
|
||||
}
|
||||
// Output the entry we'd be colliding with, for debugging purposes
|
||||
auto colliding_entry = mapInfo.find(vvTried[tried_bucket][tried_bucket_pos]);
|
||||
LogPrint(BCLog::ADDRMAN, "Collision with %s while attempting to move %s to tried table. Collisions=%d\n",
|
||||
colliding_entry != mapInfo.end() ? colliding_entry->second.ToString() : "",
|
||||
addr.ToString(),
|
||||
m_tried_collisions.size());
|
||||
} else {
|
||||
// move nId to the tried tables
|
||||
MakeTried(info, nId);
|
||||
LogPrint(BCLog::ADDRMAN, "Moved %s mapped to AS%i to tried[%i][%i]\n",
|
||||
addr.ToString(), addr.GetMappedAS(m_asmap), tried_bucket, tried_bucket_pos);
|
||||
}
|
||||
}
|
||||
|
||||
bool AddrManImpl::Add_(const std::vector<CAddress> &vAddr, const CNetAddr& source, int64_t nTimePenalty)
|
||||
{
|
||||
int added{0};
|
||||
|
|
|
@ -242,12 +242,12 @@ private:
|
|||
//! Move an entry from the "new" table(s) to the "tried" table
|
||||
void MakeTried(AddrInfo& info, int nId) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
void Good_(const CService& addr, bool test_before_evict, int64_t time) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
/** Attempt to add a single address to addrman's new table.
|
||||
* @see AddrMan::Add() for parameters. */
|
||||
bool AddSingle(const CAddress& addr, const CNetAddr& source, int64_t nTimePenalty) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
void Good_(const CService& addr, bool test_before_evict, int64_t time) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
bool Add_(const std::vector<CAddress> &vAddr, const CNetAddr& source, int64_t nTimePenalty) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
void Attempt_(const CService& addr, bool fCountFailure, int64_t nTime) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
|
Loading…
Reference in a new issue