| 3226 | } |
| 3227 | |
| 3228 | void PeerLogicValidation::CheckForStaleTipAndEvictPeers(const Consensus::Params &consensusParams) |
| 3229 | { |
| 3230 | if (connman == nullptr) return; |
| 3231 | |
| 3232 | int64_t time_in_seconds = GetTime(); |
| 3233 | |
| 3234 | EvictExtraOutboundPeers(time_in_seconds); |
| 3235 | |
| 3236 | if (time_in_seconds > m_stale_tip_check_time) { |
| 3237 | LOCK(cs_main); |
| 3238 | // Check whether our tip is stale, and if so, allow using an extra |
| 3239 | // outbound peer |
| 3240 | if (TipMayBeStale(consensusParams)) { |
| 3241 | LogPrintf("Potential stale tip detected, will try using extra outbound peer (last tip update: %d seconds ago)\n", time_in_seconds - g_last_tip_update); |
| 3242 | connman->SetTryNewOutboundPeer(true); |
| 3243 | } else if (connman->GetTryNewOutboundPeer()) { |
| 3244 | connman->SetTryNewOutboundPeer(false); |
| 3245 | } |
| 3246 | m_stale_tip_check_time = time_in_seconds + STALE_CHECK_INTERVAL; |
| 3247 | } |
| 3248 | } |
| 3249 | |
| 3250 | namespace { |
| 3251 | class CompareInvMempoolOrder |