Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 1,063 Lines • ▼ Show 20 Lines | NodeId nodeid = pnode->GetId(); | ||||
LOCK(g_peer_mutex); | LOCK(g_peer_mutex); | ||||
g_peer_map.emplace_hint(g_peer_map.end(), nodeid, std::move(peer)); | g_peer_map.emplace_hint(g_peer_map.end(), nodeid, std::move(peer)); | ||||
} | } | ||||
if (!pnode->IsInboundConn()) { | if (!pnode->IsInboundConn()) { | ||||
PushNodeVersion(config, *pnode, m_connman, GetTime()); | PushNodeVersion(config, *pnode, m_connman, GetTime()); | ||||
} | } | ||||
} | } | ||||
void PeerLogicValidation::ReattemptInitialBroadcast( | |||||
CScheduler &scheduler) const { | |||||
std::set<TxId> unbroadcast_txids = m_mempool.GetUnbroadcastTxs(); | |||||
for (const TxId &txid : unbroadcast_txids) { | |||||
RelayTransaction(txid, m_connman); | |||||
} | |||||
// schedule next run for 10-15 minutes in the future | |||||
const std::chrono::milliseconds delta = | |||||
std::chrono::minutes{10} + GetRandMillis(std::chrono::minutes{5}); | |||||
scheduler.scheduleFromNow([&] { ReattemptInitialBroadcast(scheduler); }, | |||||
delta); | |||||
} | |||||
void PeerLogicValidation::FinalizeNode(const Config &config, NodeId nodeid, | void PeerLogicValidation::FinalizeNode(const Config &config, NodeId nodeid, | ||||
bool &fUpdateConnectionTime) { | bool &fUpdateConnectionTime) { | ||||
fUpdateConnectionTime = false; | fUpdateConnectionTime = false; | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
int misbehavior{0}; | int misbehavior{0}; | ||||
{ | { | ||||
PeerRef peer = GetPeerRef(nodeid); | PeerRef peer = GetPeerRef(nodeid); | ||||
assert(peer != nullptr); | assert(peer != nullptr); | ||||
▲ Show 20 Lines • Show All 414 Lines • ▼ Show 20 Lines | static_assert( | ||||
EXTRA_PEER_CHECK_INTERVAL < STALE_CHECK_INTERVAL, | EXTRA_PEER_CHECK_INTERVAL < STALE_CHECK_INTERVAL, | ||||
"peer eviction timer should be less than stale tip check timer"); | "peer eviction timer should be less than stale tip check timer"); | ||||
scheduler.scheduleEvery( | scheduler.scheduleEvery( | ||||
[this, &consensusParams]() { | [this, &consensusParams]() { | ||||
this->CheckForStaleTipAndEvictPeers(consensusParams); | this->CheckForStaleTipAndEvictPeers(consensusParams); | ||||
return true; | return true; | ||||
}, | }, | ||||
std::chrono::seconds{EXTRA_PEER_CHECK_INTERVAL}); | std::chrono::seconds{EXTRA_PEER_CHECK_INTERVAL}); | ||||
// schedule next run for 10-15 minutes in the future | |||||
const std::chrono::milliseconds delta = | |||||
std::chrono::minutes{10} + GetRandMillis(std::chrono::minutes{5}); | |||||
scheduler.scheduleFromNow([&] { ReattemptInitialBroadcast(scheduler); }, | |||||
delta); | |||||
} | } | ||||
/** | /** | ||||
* Evict orphan txn pool entries (EraseOrphanTx) based on a newly connected | * Evict orphan txn pool entries (EraseOrphanTx) based on a newly connected | ||||
* block. Also save the time of the last tip update. | * block. Also save the time of the last tip update. | ||||
*/ | */ | ||||
void PeerLogicValidation::BlockConnected( | void PeerLogicValidation::BlockConnected( | ||||
const std::shared_ptr<const CBlock> &pblock, const CBlockIndex *pindex) { | const std::shared_ptr<const CBlock> &pblock, const CBlockIndex *pindex) { | ||||
▲ Show 20 Lines • Show All 4,004 Lines • Show Last 20 Lines |