MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ReattemptPrivateBroadcast

Method ReattemptPrivateBroadcast

src/net_processing.cpp:1656–1685  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1654}
1655
1656void PeerManagerImpl::ReattemptPrivateBroadcast(CScheduler& scheduler)
1657{
1658 // Remove stale transactions that are no longer relevant (e.g. already in
1659 // the mempool or mined) and count the remaining ones.
1660 size_t num_for_rebroadcast{0};
1661 const auto stale_txs = m_tx_for_private_broadcast.GetStale();
1662 if (!stale_txs.empty()) {
1663 LOCK(cs_main);
1664 for (const auto& stale_tx : stale_txs) {
1665 auto mempool_acceptable = m_chainman.ProcessTransaction(stale_tx, /*test_accept=*/true);
1666 if (mempool_acceptable.m_result_type == MempoolAcceptResult::ResultType::VALID) {
1667 LogDebug(BCLog::PRIVBROADCAST,
1668 "Reattempting broadcast of stale txid=%s wtxid=%s",
1669 stale_tx->GetHash().ToString(), stale_tx->GetWitnessHash().ToString());
1670 ++num_for_rebroadcast;
1671 } else {
1672 LogDebug(BCLog::PRIVBROADCAST, "Giving up broadcast attempts for txid=%s wtxid=%s: %s",
1673 stale_tx->GetHash().ToString(), stale_tx->GetWitnessHash().ToString(),
1674 mempool_acceptable.m_state.ToString());
1675 m_tx_for_private_broadcast.Remove(stale_tx);
1676 }
1677 }
1678
1679 // This could overshoot, but that is ok - we will open some private connections in vain.
1680 m_connman.m_private_broadcast.NumToOpenAdd(num_for_rebroadcast);
1681 }
1682
1683 const auto delta{2min + FastRandomContext().randrange<std::chrono::milliseconds>(1min)};
1684 scheduler.scheduleFromNow([&] { ReattemptPrivateBroadcast(scheduler); }, delta);
1685}
1686
1687void PeerManagerImpl::FinalizeNode(const CNode& node)
1688{

Callers

nothing calls this directly

Calls 7

ProcessTransactionMethod · 0.80
RemoveMethod · 0.80
NumToOpenAddMethod · 0.80
FastRandomContextClass · 0.70
emptyMethod · 0.45
ToStringMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected