refactor: Use type-safe std::chrono in net

This commit is contained in:
MarcoFalke 2021-12-13 12:02:10 +01:00
parent eb63b8fab9
commit fad7ead146
No known key found for this signature in database
GPG key ID: CE2B75697E69A548
10 changed files with 76 additions and 74 deletions

View file

@ -1023,12 +1023,12 @@ void ProtectEvictionCandidatesByRatio(std::vector<NodeEvictionCandidate>& evicti
// (vEvictionCandidates is already sorted by reverse connect time)
uint64_t naMostConnections;
unsigned int nMostConnections = 0;
int64_t nMostConnectionsTime = 0;
std::chrono::seconds nMostConnectionsTime{0};
std::map<uint64_t, std::vector<NodeEvictionCandidate> > mapNetGroupNodes;
for (const NodeEvictionCandidate &node : vEvictionCandidates) {
std::vector<NodeEvictionCandidate> &group = mapNetGroupNodes[node.nKeyedNetGroup];
group.push_back(node);
const int64_t grouptime = group[0].nTimeConnected;
const auto grouptime{group[0].nTimeConnected};
if (group.size() > nMostConnections || (group.size() == nMostConnections && grouptime > nMostConnectionsTime)) {
nMostConnections = group.size();
@ -1320,7 +1320,7 @@ void CConnman::NotifyNumConnectionsChanged()
bool CConnman::ShouldRunInactivityChecks(const CNode& node, std::chrono::seconds now) const
{
return std::chrono::seconds{node.nTimeConnected} + m_peer_connect_timeout < now;
return node.nTimeConnected + m_peer_connect_timeout < now;
}
bool CConnman::InactivityCheck(const CNode& node) const