28 const auto p{DerivePriority(
handle.mapped())};
29 return p.num_confirmed;
39 const auto it{std::ranges::max_element(
41 [](
const auto&
a,
const auto& b) {
return a < b; },
42 [](
const auto&
el) {
return DerivePriority(
el.second); })};
80 return tx_and_status.value().send_status.confirmed.has_value();
97 std::vector<CTransactionRef>
stale;
111 std::vector<TxBroadcastInfo> entries;
115 std::vector<PeerSendInfo> peers;
117 for (
const auto& status :
sent_to) {
118 peers.emplace_back(
PeerSendInfo{.
address = status.address, .sent = status.picked, .received = status.confirmed});
130 for (
const auto& send_status :
sent_to) {
131 p.last_picked = std::max(
p.last_picked, send_status.picked);
132 if (send_status.confirmed.has_value()) {
134 p.last_confirmed = std::max(
p.last_confirmed, send_status.confirmed.value());
145 for (
auto& send_status :
sent_to) {
146 if (send_status.nodeid == nodeid) {
A combination of a network address (CNetAddr) and a (TCP) port.
static Priority DerivePriority(const std::vector< SendStatus > &sent_to)
Derive the sending priority of a transaction.
void NodeConfirmedReception(const NodeId &nodeid) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Mark that the node has confirmed reception of the transaction we sent it by responding with PONG to o...
std::vector< TxBroadcastInfo > GetBroadcastInfo() const EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Get stats about all transactions currently being privately broadcast.
bool HavePendingTransactions() EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Check if there are transactions that need to be broadcast.
bool DidNodeConfirmReception(const NodeId &nodeid) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Check if the node has confirmed reception of the transaction.
std::optional< size_t > Remove(const CTransactionRef &tx) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Forget a transaction.
std::optional< CTransactionRef > PickTxForSend(const NodeId &will_send_to_nodeid, const CService &will_send_to_address) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Pick the transaction with the fewest send attempts, and confirmations, and oldest send/confirm times.
std::optional< TxAndSendStatusForNode > GetSendStatusByNode(const NodeId &nodeid) EXCLUSIVE_LOCKS_REQUIRED(m_mutex)
Find which transaction we sent to a given node (marked by PickTxForSend()).
std::optional< CTransactionRef > GetTxForNode(const NodeId &nodeid) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Get the transaction that was picked for sending to a given node by PickTxForSend().
bool Add(const CTransactionRef &tx) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Add a transaction to the storage.
std::vector< CTransactionRef > GetStale() const EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Get the transactions that have not been broadcast recently.
std::shared_ptr< const CTransaction > CTransactionRef
static constexpr auto STALE_DURATION
If a transaction is not received back from the network for this duration after it is broadcast,...
static time_point now() noexcept
Return current system time or mocked time, if set.
Cumulative stats from all the send attempts for a transaction. Used to prioritize transactions.
size_t num_picked
Number of times the transaction was picked for sending.
A pair of a transaction and a sent status for a given node. Convenience return type of GetSendStatusB...
const CTransactionRef & tx
#define AssertLockHeld(cs)
#define EXCLUSIVE_LOCKS_REQUIRED(...)
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.