Skip to content

Commit

Permalink
Merge pull request #6283
Browse files Browse the repository at this point in the history
26a639e remove using namespace std from addrman.cpp (Philip Kaufmann)
40c592a make CAddrMan::size() return the correct type of size_t (Philip Kaufmann)
  • Loading branch information
laanwj committed Jun 16, 2015
2 parents 7fe29d8 + 26a639e commit a903ad7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/addrman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#include "serialize.h"
#include "streams.h"

using namespace std;

int CAddrInfo::GetTriedBucket(const uint256& nKey) const
{
uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << GetKey()).GetHash().GetCheapHash();
Expand Down Expand Up @@ -68,7 +66,7 @@ double CAddrInfo::GetChance(int64_t nNow) const
fChance *= 0.01;

// deprioritize 66% after each failed attempt, but at most 1/28th to avoid the search taking forever or overly penalizing outages.
fChance *= pow(0.66, min(nAttempts, 8));
fChance *= pow(0.66, std::min(nAttempts, 8));

return fChance;
}
Expand Down Expand Up @@ -258,7 +256,7 @@ bool CAddrMan::Add_(const CAddress& addr, const CNetAddr& source, int64_t nTimeP
bool fCurrentlyOnline = (GetAdjustedTime() - addr.nTime < 24 * 60 * 60);
int64_t nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60);
if (addr.nTime && (!pinfo->nTime || pinfo->nTime < addr.nTime - nUpdateInterval - nTimePenalty))
pinfo->nTime = max((int64_t)0, addr.nTime - nTimePenalty);
pinfo->nTime = std::max((int64_t)0, addr.nTime - nTimePenalty);

// add services
pinfo->nServices |= addr.nServices;
Expand All @@ -283,7 +281,7 @@ bool CAddrMan::Add_(const CAddress& addr, const CNetAddr& source, int64_t nTimeP
return false;
} else {
pinfo = Create(addr, source, &nId);
pinfo->nTime = max((int64_t)0, (int64_t)pinfo->nTime - nTimePenalty);
pinfo->nTime = std::max((int64_t)0, (int64_t)pinfo->nTime - nTimePenalty);
nNew++;
fNew = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/addrman.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ class CAddrMan
}

//! Return the number of (unique) addresses in all tables.
int size()
size_t size() const
{
return vRandom.size();
}
Expand Down

0 comments on commit a903ad7

Please sign in to comment.