![]() |
Bitcoin Core 30.99.0
P2P Digital Currency
|
Store a list of transactions to be broadcast privately. More...
#include <private_broadcast.h>
Classes | |
| struct | CTransactionRefComp |
| struct | CTransactionRefHash |
| struct | Priority |
| Cumulative stats from all the send attempts for a transaction. Used to prioritize transactions. More... | |
| struct | SendStatus |
| Status of a transaction sent to a given node. More... | |
| struct | TxAndSendStatusForNode |
| A pair of a transaction and a sent status for a given node. Convenience return type of GetSendStatusByNode(). More... | |
Public Member Functions | |
| bool | Add (const CTransactionRef &tx) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
| Add a transaction to the storage. More... | |
| std::optional< size_t > | Remove (const CTransactionRef &tx) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
| Forget a transaction. More... | |
| std::optional< CTransactionRef > | PickTxForSend (const NodeId &will_send_to_nodeid) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
| Pick the transaction with the fewest send attempts, and confirmations, and oldest send/confirm times. More... | |
| 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(). More... | |
| 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 our PING message. More... | |
| bool | DidNodeConfirmReception (const NodeId &nodeid) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
| Check if the node has confirmed reception of the transaction. More... | |
| bool | HavePendingTransactions () EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
| Check if there are transactions that need to be broadcast. More... | |
| std::vector< CTransactionRef > | GetStale () const EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
| Get the transactions that have not been broadcast recently. More... | |
Private Member Functions | |
| std::optional< TxAndSendStatusForNode > | GetSendStatusByNode (const NodeId &nodeid) EXCLUSIVE_LOCKS_REQUIRED(m_mutex) |
| Find which transaction we sent to a given node (marked by PickTxForSend()). More... | |
| std::unordered_map< CTransactionRef, std::vector< SendStatus >, CTransactionRefHash, CTransactionRefComp > m_transactions | GUARDED_BY (m_mutex) |
Static Private Member Functions | |
| static Priority | DerivePriority (const std::vector< SendStatus > &sent_to) |
| Derive the sending priority of a transaction. More... | |
Private Attributes | |
| Mutex | m_mutex |
Store a list of transactions to be broadcast privately.
Supports the following operations:
Definition at line 30 of file private_broadcast.h.
| bool PrivateBroadcast::Add | ( | const CTransactionRef & | tx | ) |
Add a transaction to the storage.
| [in] | tx | The transaction to add. |
| true | The transaction was added. |
| false | The transaction was already present. |
Definition at line 14 of file private_broadcast.cpp.
|
staticprivate |
Derive the sending priority of a transaction.
| [in] | sent_to | List of nodes that the transaction has been sent to. |
Definition at line 107 of file private_broadcast.cpp.
| bool PrivateBroadcast::DidNodeConfirmReception | ( | const NodeId & | nodeid | ) |
Check if the node has confirmed reception of the transaction.
| true | Node has confirmed, NodeConfirmedReception() has been called. |
| false | Node has not confirmed, NodeConfirmedReception() has not been called. |
Definition at line 74 of file private_broadcast.cpp.
|
private |
Find which transaction we sent to a given node (marked by PickTxForSend()).
Definition at line 121 of file private_broadcast.cpp.
| std::vector< CTransactionRef > PrivateBroadcast::GetStale | ( | ) | const |
Get the transactions that have not been broadcast recently.
Definition at line 92 of file private_broadcast.cpp.
| std::optional< CTransactionRef > PrivateBroadcast::GetTxForNode | ( | const NodeId & | nodeid | ) |
Get the transaction that was picked for sending to a given node by PickTxForSend().
| [in] | nodeid | Node to which a transaction is being (or was) sent. |
Definition at line 53 of file private_broadcast.cpp.
|
private |
| bool PrivateBroadcast::HavePendingTransactions | ( | ) |
Check if there are transactions that need to be broadcast.
Definition at line 85 of file private_broadcast.cpp.
| void PrivateBroadcast::NodeConfirmedReception | ( | const NodeId & | nodeid | ) |
Mark that the node has confirmed reception of the transaction we sent it by responding with PONG to our PING message.
| [in] | nodeid | Node that we sent a transaction to. |
Definition at line 64 of file private_broadcast.cpp.
| std::optional< CTransactionRef > PrivateBroadcast::PickTxForSend | ( | const NodeId & | will_send_to_nodeid | ) |
Pick the transaction with the fewest send attempts, and confirmations, and oldest send/confirm times.
| [in] | will_send_to_nodeid | Will remember that the returned transaction was picked for sending to this node. |
Definition at line 34 of file private_broadcast.cpp.
| std::optional< size_t > PrivateBroadcast::Remove | ( | const CTransactionRef & | tx | ) |
Forget a transaction.
| [in] | tx | Transaction to forget. |
| !nullopt | The number of times the transaction was sent and confirmed by the recipient (if the transaction existed and was removed). |
| nullopt | The transaction was not in the storage. |
Definition at line 22 of file private_broadcast.cpp.
|
mutableprivate |
Definition at line 161 of file private_broadcast.h.