Merge #9052: Use RelevantServices instead of node_network in AttemptToEvict.

d32036a Use RelevantServices instead of node_network in AttemptToEvict. (Gregory Maxwell)
This commit is contained in:
Wladimir J. van der Laan 2016-11-07 13:13:29 +01:00
commit c113a651f1
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6

View File

@ -809,7 +809,7 @@ struct NodeEvictionCandidate
int64_t nMinPingUsecTime; int64_t nMinPingUsecTime;
int64_t nLastBlockTime; int64_t nLastBlockTime;
int64_t nLastTXTime; int64_t nLastTXTime;
bool fNetworkNode; bool fRelevantServices;
bool fRelayTxes; bool fRelayTxes;
bool fBloomFilter; bool fBloomFilter;
CAddress addr; CAddress addr;
@ -834,7 +834,7 @@ static bool CompareNodeBlockTime(const NodeEvictionCandidate &a, const NodeEvict
{ {
// There is a fall-through here because it is common for a node to have many peers which have not yet relayed a block. // There is a fall-through here because it is common for a node to have many peers which have not yet relayed a block.
if (a.nLastBlockTime != b.nLastBlockTime) return a.nLastBlockTime < b.nLastBlockTime; if (a.nLastBlockTime != b.nLastBlockTime) return a.nLastBlockTime < b.nLastBlockTime;
if (a.fNetworkNode != b.fNetworkNode) return b.fNetworkNode; if (a.fRelevantServices != b.fRelevantServices) return b.fRelevantServices;
return a.nTimeConnected > b.nTimeConnected; return a.nTimeConnected > b.nTimeConnected;
} }
@ -869,7 +869,8 @@ bool CConnman::AttemptToEvictConnection()
if (node->fDisconnect) if (node->fDisconnect)
continue; continue;
NodeEvictionCandidate candidate = {node->id, node->nTimeConnected, node->nMinPingUsecTime, NodeEvictionCandidate candidate = {node->id, node->nTimeConnected, node->nMinPingUsecTime,
node->nLastBlockTime, node->nLastTXTime, node->fNetworkNode, node->nLastBlockTime, node->nLastTXTime,
(node->nServices & nRelevantServices) == nRelevantServices,
node->fRelayTxes, node->pfilter != NULL, node->addr, node->nKeyedNetGroup}; node->fRelayTxes, node->pfilter != NULL, node->addr, node->nKeyedNetGroup};
vEvictionCandidates.push_back(candidate); vEvictionCandidates.push_back(candidate);
} }