mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
[style] Run changed files through clang formatter.
This commit is contained in:
parent
375750387e
commit
021f86953e
4 changed files with 34 additions and 34 deletions
|
@ -41,7 +41,7 @@ static constexpr size_t ADDRMAN_SET_TRIED_COLLISION_SIZE{10};
|
||||||
/** The maximum time we'll spend trying to resolve a tried table collision, in seconds */
|
/** The maximum time we'll spend trying to resolve a tried table collision, in seconds */
|
||||||
static constexpr int64_t ADDRMAN_TEST_WINDOW{40*60}; // 40 minutes
|
static constexpr int64_t ADDRMAN_TEST_WINDOW{40*60}; // 40 minutes
|
||||||
|
|
||||||
int AddrInfo::GetTriedBucket(const uint256& nKey, const std::vector<bool> &asmap) const
|
int AddrInfo::GetTriedBucket(const uint256& nKey, const std::vector<bool>& asmap) const
|
||||||
{
|
{
|
||||||
uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << GetKey()).GetCheapHash();
|
uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << GetKey()).GetCheapHash();
|
||||||
uint64_t hash2 = (CHashWriter(SER_GETHASH, 0) << nKey << GetGroup(asmap) << (hash1 % ADDRMAN_TRIED_BUCKETS_PER_GROUP)).GetCheapHash();
|
uint64_t hash2 = (CHashWriter(SER_GETHASH, 0) << nKey << GetGroup(asmap) << (hash1 % ADDRMAN_TRIED_BUCKETS_PER_GROUP)).GetCheapHash();
|
||||||
|
@ -51,7 +51,7 @@ int AddrInfo::GetTriedBucket(const uint256& nKey, const std::vector<bool> &asmap
|
||||||
return tried_bucket;
|
return tried_bucket;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AddrInfo::GetNewBucket(const uint256& nKey, const CNetAddr& src, const std::vector<bool> &asmap) const
|
int AddrInfo::GetNewBucket(const uint256& nKey, const CNetAddr& src, const std::vector<bool>& asmap) const
|
||||||
{
|
{
|
||||||
std::vector<unsigned char> vchSourceGroupKey = src.GetGroup(asmap);
|
std::vector<unsigned char> vchSourceGroupKey = src.GetGroup(asmap);
|
||||||
uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << GetGroup(asmap) << vchSourceGroupKey).GetCheapHash();
|
uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << GetGroup(asmap) << vchSourceGroupKey).GetCheapHash();
|
||||||
|
@ -62,7 +62,7 @@ int AddrInfo::GetNewBucket(const uint256& nKey, const CNetAddr& src, const std::
|
||||||
return new_bucket;
|
return new_bucket;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AddrInfo::GetBucketPosition(const uint256 &nKey, bool fNew, int nBucket) const
|
int AddrInfo::GetBucketPosition(const uint256& nKey, bool fNew, int nBucket) const
|
||||||
{
|
{
|
||||||
uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << (fNew ? uint8_t{'N'} : uint8_t{'K'}) << nBucket << GetKey()).GetCheapHash();
|
uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << (fNew ? uint8_t{'N'} : uint8_t{'K'}) << nBucket << GetKey()).GetCheapHash();
|
||||||
return hash1 % ADDRMAN_BUCKET_SIZE;
|
return hash1 % ADDRMAN_BUCKET_SIZE;
|
||||||
|
@ -190,7 +190,7 @@ void AddrManImpl::Serialize(Stream& s_) const
|
||||||
int nIds = 0;
|
int nIds = 0;
|
||||||
for (const auto& entry : mapInfo) {
|
for (const auto& entry : mapInfo) {
|
||||||
mapUnkIds[entry.first] = nIds;
|
mapUnkIds[entry.first] = nIds;
|
||||||
const AddrInfo &info = entry.second;
|
const AddrInfo& info = entry.second;
|
||||||
if (info.nRefCount) {
|
if (info.nRefCount) {
|
||||||
assert(nIds != nNew); // this means nNew was wrong, oh ow
|
assert(nIds != nNew); // this means nNew was wrong, oh ow
|
||||||
s << info;
|
s << info;
|
||||||
|
@ -199,7 +199,7 @@ void AddrManImpl::Serialize(Stream& s_) const
|
||||||
}
|
}
|
||||||
nIds = 0;
|
nIds = 0;
|
||||||
for (const auto& entry : mapInfo) {
|
for (const auto& entry : mapInfo) {
|
||||||
const AddrInfo &info = entry.second;
|
const AddrInfo& info = entry.second;
|
||||||
if (info.fInTried) {
|
if (info.fInTried) {
|
||||||
assert(nIds != nTried); // this means nTried was wrong, oh ow
|
assert(nIds != nTried); // this means nTried was wrong, oh ow
|
||||||
s << info;
|
s << info;
|
||||||
|
@ -283,7 +283,7 @@ void AddrManImpl::Unserialize(Stream& s_)
|
||||||
|
|
||||||
// Deserialize entries from the new table.
|
// Deserialize entries from the new table.
|
||||||
for (int n = 0; n < nNew; n++) {
|
for (int n = 0; n < nNew; n++) {
|
||||||
AddrInfo &info = mapInfo[n];
|
AddrInfo& info = mapInfo[n];
|
||||||
s >> info;
|
s >> info;
|
||||||
mapAddr[info] = n;
|
mapAddr[info] = n;
|
||||||
info.nRandomPos = vRandom.size();
|
info.nRandomPos = vRandom.size();
|
||||||
|
@ -1024,7 +1024,7 @@ size_t AddrManImpl::size() const
|
||||||
return vRandom.size();
|
return vRandom.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddrManImpl::Add(const std::vector<CAddress> &vAddr, const CNetAddr& source, int64_t nTimePenalty)
|
bool AddrManImpl::Add(const std::vector<CAddress>& vAddr, const CNetAddr& source, int64_t nTimePenalty)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
int nAdd = 0;
|
int nAdd = 0;
|
||||||
|
@ -1038,7 +1038,7 @@ bool AddrManImpl::Add(const std::vector<CAddress> &vAddr, const CNetAddr& source
|
||||||
return nAdd > 0;
|
return nAdd > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddrManImpl::Good(const CService &addr, int64_t nTime)
|
void AddrManImpl::Good(const CService& addr, int64_t nTime)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
Check();
|
Check();
|
||||||
|
@ -1046,7 +1046,7 @@ void AddrManImpl::Good(const CService &addr, int64_t nTime)
|
||||||
Check();
|
Check();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddrManImpl::Attempt(const CService &addr, bool fCountFailure, int64_t nTime)
|
void AddrManImpl::Attempt(const CService& addr, bool fCountFailure, int64_t nTime)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
Check();
|
Check();
|
||||||
|
@ -1089,7 +1089,7 @@ std::vector<CAddress> AddrManImpl::GetAddr(size_t max_addresses, size_t max_pct,
|
||||||
return addresses;
|
return addresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddrManImpl::Connected(const CService &addr, int64_t nTime)
|
void AddrManImpl::Connected(const CService& addr, int64_t nTime)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
Check();
|
Check();
|
||||||
|
@ -1097,7 +1097,7 @@ void AddrManImpl::Connected(const CService &addr, int64_t nTime)
|
||||||
Check();
|
Check();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddrManImpl::SetServices(const CService &addr, ServiceFlags nServices)
|
void AddrManImpl::SetServices(const CService& addr, ServiceFlags nServices)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
Check();
|
Check();
|
||||||
|
@ -1141,17 +1141,17 @@ size_t AddrMan::size() const
|
||||||
return m_impl->size();
|
return m_impl->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddrMan::Add(const std::vector<CAddress> &vAddr, const CNetAddr& source, int64_t nTimePenalty)
|
bool AddrMan::Add(const std::vector<CAddress>& vAddr, const CNetAddr& source, int64_t nTimePenalty)
|
||||||
{
|
{
|
||||||
return m_impl->Add(vAddr, source, nTimePenalty);
|
return m_impl->Add(vAddr, source, nTimePenalty);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddrMan::Good(const CService &addr, int64_t nTime)
|
void AddrMan::Good(const CService& addr, int64_t nTime)
|
||||||
{
|
{
|
||||||
m_impl->Good(addr, nTime);
|
m_impl->Good(addr, nTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddrMan::Attempt(const CService &addr, bool fCountFailure, int64_t nTime)
|
void AddrMan::Attempt(const CService& addr, bool fCountFailure, int64_t nTime)
|
||||||
{
|
{
|
||||||
m_impl->Attempt(addr, fCountFailure, nTime);
|
m_impl->Attempt(addr, fCountFailure, nTime);
|
||||||
}
|
}
|
||||||
|
@ -1176,12 +1176,12 @@ std::vector<CAddress> AddrMan::GetAddr(size_t max_addresses, size_t max_pct, std
|
||||||
return m_impl->GetAddr(max_addresses, max_pct, network);
|
return m_impl->GetAddr(max_addresses, max_pct, network);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddrMan::Connected(const CService &addr, int64_t nTime)
|
void AddrMan::Connected(const CService& addr, int64_t nTime)
|
||||||
{
|
{
|
||||||
m_impl->Connected(addr, nTime);
|
m_impl->Connected(addr, nTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddrMan::SetServices(const CService &addr, ServiceFlags nServices)
|
void AddrMan::SetServices(const CService& addr, ServiceFlags nServices)
|
||||||
{
|
{
|
||||||
m_impl->SetServices(addr, nServices);
|
m_impl->SetServices(addr, nServices);
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,13 +70,13 @@ public:
|
||||||
size_t size() const;
|
size_t size() const;
|
||||||
|
|
||||||
//! Add addresses to addrman's new table.
|
//! Add addresses to addrman's new table.
|
||||||
bool Add(const std::vector<CAddress> &vAddr, const CNetAddr& source, int64_t nTimePenalty = 0);
|
bool Add(const std::vector<CAddress>& vAddr, const CNetAddr& source, int64_t nTimePenalty = 0);
|
||||||
|
|
||||||
//! Mark an entry as accessible, possibly moving it from "new" to "tried".
|
//! Mark an entry as accessible, possibly moving it from "new" to "tried".
|
||||||
void Good(const CService &addr, int64_t nTime = GetAdjustedTime());
|
void Good(const CService& addr, int64_t nTime = GetAdjustedTime());
|
||||||
|
|
||||||
//! Mark an entry as connection attempted to.
|
//! Mark an entry as connection attempted to.
|
||||||
void Attempt(const CService &addr, bool fCountFailure, int64_t nTime = GetAdjustedTime());
|
void Attempt(const CService& addr, bool fCountFailure, int64_t nTime = GetAdjustedTime());
|
||||||
|
|
||||||
//! See if any to-be-evicted tried table entries have been tested and if so resolve the collisions.
|
//! See if any to-be-evicted tried table entries have been tested and if so resolve the collisions.
|
||||||
void ResolveCollisions();
|
void ResolveCollisions();
|
||||||
|
@ -121,10 +121,10 @@ public:
|
||||||
* @param[in] addr The address of the peer we were connected to
|
* @param[in] addr The address of the peer we were connected to
|
||||||
* @param[in] nTime The time that we were last connected to this peer
|
* @param[in] nTime The time that we were last connected to this peer
|
||||||
*/
|
*/
|
||||||
void Connected(const CService &addr, int64_t nTime = GetAdjustedTime());
|
void Connected(const CService& addr, int64_t nTime = GetAdjustedTime());
|
||||||
|
|
||||||
//! Update an entry's service bits.
|
//! Update an entry's service bits.
|
||||||
void SetServices(const CService &addr, ServiceFlags nServices);
|
void SetServices(const CService& addr, ServiceFlags nServices);
|
||||||
|
|
||||||
const std::vector<bool>& GetAsmap() const;
|
const std::vector<bool>& GetAsmap() const;
|
||||||
|
|
||||||
|
|
|
@ -111,29 +111,29 @@ public:
|
||||||
|
|
||||||
size_t size() const EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
size_t size() const EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
||||||
|
|
||||||
bool Add(const std::vector<CAddress> &vAddr, const CNetAddr& source, int64_t nTimePenalty)
|
bool Add(const std::vector<CAddress>& vAddr, const CNetAddr& source, int64_t nTimePenalty)
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
||||||
|
|
||||||
void Good(const CService &addr, int64_t nTime)
|
void Good(const CService& addr, int64_t nTime)
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
||||||
|
|
||||||
void Attempt(const CService &addr, bool fCountFailure, int64_t nTime)
|
void Attempt(const CService& addr, bool fCountFailure, int64_t nTime)
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
||||||
|
|
||||||
void ResolveCollisions() EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
void ResolveCollisions() EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
||||||
|
|
||||||
std::pair<CAddress, int64_t> SelectTriedCollision() EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
std::pair<CAddress, int64_t> SelectTriedCollision() EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
||||||
|
|
||||||
std::pair<CAddress, int64_t> Select(bool newOnly) const
|
std::pair<CAddress, int64_t> Select(bool newOnly) const
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
||||||
|
|
||||||
std::vector<CAddress> GetAddr(size_t max_addresses, size_t max_pct, std::optional<Network> network) const
|
std::vector<CAddress> GetAddr(size_t max_addresses, size_t max_pct, std::optional<Network> network) const
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
||||||
|
|
||||||
void Connected(const CService &addr, int64_t nTime)
|
void Connected(const CService& addr, int64_t nTime)
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
||||||
|
|
||||||
void SetServices(const CService &addr, ServiceFlags nServices)
|
void SetServices(const CService& addr, ServiceFlags nServices)
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
||||||
|
|
||||||
const std::vector<bool>& GetAsmap() const;
|
const std::vector<bool>& GetAsmap() const;
|
||||||
|
@ -225,10 +225,10 @@ private:
|
||||||
const std::vector<bool> m_asmap;
|
const std::vector<bool> m_asmap;
|
||||||
|
|
||||||
//! Find an entry.
|
//! Find an entry.
|
||||||
AddrInfo* Find(const CNetAddr& addr, int *pnId = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
AddrInfo* Find(const CNetAddr& addr, int* pnId = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||||
|
|
||||||
//! Create a new entry and add it to the internal data structures mapInfo, mapAddr and vRandom.
|
//! Create a new entry and add it to the internal data structures mapInfo, mapAddr and vRandom.
|
||||||
AddrInfo* Create(const CAddress &addr, const CNetAddr &addrSource, int *pnId = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
AddrInfo* Create(const CAddress& addr, const CNetAddr& addrSource, int* pnId = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||||
|
|
||||||
//! Swap two elements in vRandom.
|
//! Swap two elements in vRandom.
|
||||||
void SwapRandom(unsigned int nRandomPos1, unsigned int nRandomPos2) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
void SwapRandom(unsigned int nRandomPos1, unsigned int nRandomPos2) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||||
|
@ -242,11 +242,11 @@ private:
|
||||||
//! Move an entry from the "new" table(s) to the "tried" table
|
//! Move an entry from the "new" table(s) to the "tried" table
|
||||||
void MakeTried(AddrInfo& info, int nId) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
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);
|
void Good_(const CService& addr, bool test_before_evict, int64_t time) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||||
|
|
||||||
bool Add_(const CAddress &addr, const CNetAddr& source, int64_t nTimePenalty) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
bool Add_(const CAddress& addr, const CNetAddr& source, int64_t nTimePenalty) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||||
|
|
||||||
void Attempt_(const CService &addr, bool fCountFailure, int64_t nTime) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
void Attempt_(const CService& addr, bool fCountFailure, int64_t nTime) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||||
|
|
||||||
std::pair<CAddress, int64_t> Select_(bool newOnly) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
std::pair<CAddress, int64_t> Select_(bool newOnly) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ private:
|
||||||
|
|
||||||
void Connected_(const CService& addr, int64_t nTime) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
void Connected_(const CService& addr, int64_t nTime) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||||
|
|
||||||
void SetServices_(const CService &addr, ServiceFlags nServices) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
void SetServices_(const CService& addr, ServiceFlags nServices) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||||
|
|
||||||
void ResolveCollisions_() EXCLUSIVE_LOCKS_REQUIRED(cs);
|
void ResolveCollisions_() EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ private:
|
||||||
bool deterministic;
|
bool deterministic;
|
||||||
public:
|
public:
|
||||||
explicit AddrManTest(bool makeDeterministic = true,
|
explicit AddrManTest(bool makeDeterministic = true,
|
||||||
std::vector<bool> asmap = std::vector<bool>())
|
std::vector<bool> asmap = std::vector<bool>())
|
||||||
: AddrMan(asmap, makeDeterministic, /* consistency_check_ratio */ 100)
|
: AddrMan(asmap, makeDeterministic, /* consistency_check_ratio */ 100)
|
||||||
{
|
{
|
||||||
deterministic = makeDeterministic;
|
deterministic = makeDeterministic;
|
||||||
|
|
Loading…
Add table
Reference in a new issue