Skip to content

Commit d32036a

Browse files
committed
Use RelevantServices instead of node_network in AttemptToEvict.
Use of node_network here is really meant to be a proxy of "likely to send us blocks in the future". RelevantServices is the right criteria now.
1 parent 3d69ecb commit d32036a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/net.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ struct NodeEvictionCandidate
825825
int64_t nMinPingUsecTime;
826826
int64_t nLastBlockTime;
827827
int64_t nLastTXTime;
828-
bool fNetworkNode;
828+
bool fRelevantServices;
829829
bool fRelayTxes;
830830
bool fBloomFilter;
831831
CAddress addr;
@@ -850,7 +850,7 @@ static bool CompareNodeBlockTime(const NodeEvictionCandidate &a, const NodeEvict
850850
{
851851
// There is a fall-through here because it is common for a node to have many peers which have not yet relayed a block.
852852
if (a.nLastBlockTime != b.nLastBlockTime) return a.nLastBlockTime < b.nLastBlockTime;
853-
if (a.fNetworkNode != b.fNetworkNode) return b.fNetworkNode;
853+
if (a.fRelevantServices != b.fRelevantServices) return b.fRelevantServices;
854854
return a.nTimeConnected > b.nTimeConnected;
855855
}
856856

@@ -885,7 +885,8 @@ bool CConnman::AttemptToEvictConnection()
885885
if (node->fDisconnect)
886886
continue;
887887
NodeEvictionCandidate candidate = {node->id, node->nTimeConnected, node->nMinPingUsecTime,
888-
node->nLastBlockTime, node->nLastTXTime, node->fNetworkNode,
888+
node->nLastBlockTime, node->nLastTXTime,
889+
(node->nServices & nRelevantServices) == nRelevantServices,
889890
node->fRelayTxes, node->pfilter != NULL, node->addr, node->nKeyedNetGroup};
890891
vEvictionCandidates.push_back(candidate);
891892
}

0 commit comments

Comments
 (0)