mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-08 21:59:10 +02:00
node: change a tx-relay on/off flag to enum
Previously the `bool relay` argument to `BroadcastTransaction()` designated: ``` relay=true: add to the mempool and broadcast to all peers relay=false: add to the mempool ``` Change this to an `enum`, so it is more readable and easier to extend with a 3rd option. Consider these example call sites: ```cpp Paint(true); // Or Paint(/*is_red=*/true); ``` vs ```cpp Paint(RED); ``` The idea for putting `TxBroadcastMethod` into `node/types.h` by Ryan. Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <blockfilter.h>
|
||||
#include <common/settings.h>
|
||||
#include <node/types.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <util/result.h>
|
||||
|
||||
@@ -206,13 +207,19 @@ public:
|
||||
//! Check if transaction has descendants in mempool.
|
||||
virtual bool hasDescendantsInMempool(const Txid& txid) = 0;
|
||||
|
||||
//! Transaction is added to memory pool, if the transaction fee is below the
|
||||
//! amount specified by max_tx_fee, and broadcast to all peers if relay is set to true.
|
||||
//! Return false if the transaction could not be added due to the fee or for another reason.
|
||||
//! Process a local transaction, optionally adding it to the mempool and
|
||||
//! optionally broadcasting it to the network.
|
||||
//! @param[in] tx Transaction to process.
|
||||
//! @param[in] max_tx_fee Don't add the transaction to the mempool or
|
||||
//! broadcast it if its fee is higher than this.
|
||||
//! @param[in] broadcast_method Whether to add the transaction to the
|
||||
//! mempool and how/whether to broadcast it.
|
||||
//! @param[out] err_string Set if an error occurs.
|
||||
//! @return False if the transaction could not be added due to the fee or for another reason.
|
||||
virtual bool broadcastTransaction(const CTransactionRef& tx,
|
||||
const CAmount& max_tx_fee,
|
||||
bool relay,
|
||||
std::string& err_string) = 0;
|
||||
const CAmount& max_tx_fee,
|
||||
node::TxBroadcast broadcast_method,
|
||||
std::string& err_string) = 0;
|
||||
|
||||
//! Calculate mempool ancestor and descendant counts for the given transaction.
|
||||
virtual void getTransactionAncestry(const Txid& txid, size_t& ancestors, size_t& descendants, size_t* ancestorsize = nullptr, CAmount* ancestorfees = nullptr) = 0;
|
||||
|
||||
Reference in New Issue
Block a user