mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 23:07:59 +01:00
[p2p] Reattempt initial send of unbroadcast transactions
Every 10-15 minutes, the scheduler kicks off a job that queues unbroadcast transactions onto each node.
This commit is contained in:
parent
7e93eecce3
commit
e25e42f20a
2 changed files with 19 additions and 0 deletions
|
@ -779,6 +779,19 @@ void PeerLogicValidation::InitializeNode(CNode *pnode) {
|
||||||
PushNodeVersion(pnode, connman, GetTime());
|
PushNodeVersion(pnode, connman, GetTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PeerLogicValidation::ReattemptInitialBroadcast(CScheduler& scheduler) const
|
||||||
|
{
|
||||||
|
std::set<uint256> unbroadcast_txids = m_mempool.GetUnbroadcastTxs();
|
||||||
|
|
||||||
|
for (const uint256& txid : unbroadcast_txids) {
|
||||||
|
RelayTransaction(txid, *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(NodeId nodeid, bool& fUpdateConnectionTime) {
|
void PeerLogicValidation::FinalizeNode(NodeId nodeid, bool& fUpdateConnectionTime) {
|
||||||
fUpdateConnectionTime = false;
|
fUpdateConnectionTime = false;
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
@ -1128,6 +1141,10 @@ PeerLogicValidation::PeerLogicValidation(CConnman* connmanIn, BanMan* banman, CS
|
||||||
// timer.
|
// timer.
|
||||||
static_assert(EXTRA_PEER_CHECK_INTERVAL < STALE_CHECK_INTERVAL, "peer eviction timer should be less than stale tip check timer");
|
static_assert(EXTRA_PEER_CHECK_INTERVAL < STALE_CHECK_INTERVAL, "peer eviction timer should be less than stale tip check timer");
|
||||||
scheduler.scheduleEvery([this, consensusParams] { this->CheckForStaleTipAndEvictPeers(consensusParams); }, std::chrono::seconds{EXTRA_PEER_CHECK_INTERVAL});
|
scheduler.scheduleEvery([this, consensusParams] { this->CheckForStaleTipAndEvictPeers(consensusParams); }, 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -75,6 +75,8 @@ public:
|
||||||
void CheckForStaleTipAndEvictPeers(const Consensus::Params &consensusParams);
|
void CheckForStaleTipAndEvictPeers(const Consensus::Params &consensusParams);
|
||||||
/** If we have extra outbound peers, try to disconnect the one with the oldest block announcement */
|
/** If we have extra outbound peers, try to disconnect the one with the oldest block announcement */
|
||||||
void EvictExtraOutboundPeers(int64_t time_in_seconds) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
void EvictExtraOutboundPeers(int64_t time_in_seconds) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||||
|
/** Retrieve unbroadcast transactions from the mempool and reattempt sending to peers */
|
||||||
|
void ReattemptInitialBroadcast(CScheduler& scheduler) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int64_t m_stale_tip_check_time; //!< Next time to check for stale tip
|
int64_t m_stale_tip_check_time; //!< Next time to check for stale tip
|
||||||
|
|
Loading…
Add table
Reference in a new issue