mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-19 02:13:37 +02:00
txgraph: initialize Ref in AddTransaction (preparation)
Instead of returning a TxGraph::Ref from TxGraph::AddTransaction(), pass in a TxGraph::Ref& which is updated to refer to the new transaction in that graph. This cleans up the usage somewhat, avoiding the need for dummy Refs in CTxMemPoolEntry constructor calls, but the motivation is that a future commit will allow a callback to passed to MakeTxGraph to define a fallback order on the transaction objects. This does not work when a Ref is created separately from the CTxMemPoolEntry it ends up living in, as passing the newly-created Ref to the callback would be UB before it's emplaced in its final CTxMemPoolEntry.
This commit is contained in:
@@ -67,7 +67,7 @@ void BenchTxGraphTrim(benchmark::Bench& bench)
|
||||
for (int chaintx = 0; chaintx < NUM_TX_PER_TOP_CHAIN; ++chaintx) {
|
||||
int64_t fee = rng.randbits<27>() + 100;
|
||||
FeePerWeight feerate{fee, 1};
|
||||
top_refs.push_back(graph->AddTransaction(feerate));
|
||||
graph->AddTransaction(top_refs.emplace_back(), feerate);
|
||||
// Add internal dependencies linking the chain transactions together.
|
||||
if (chaintx > 0) {
|
||||
graph->AddDependency(*(top_refs.rbegin()), *(top_refs.rbegin() + 1));
|
||||
@@ -85,7 +85,8 @@ void BenchTxGraphTrim(benchmark::Bench& bench)
|
||||
// Construct the transaction.
|
||||
int64_t fee = rng.randbits<27>() + 100;
|
||||
FeePerWeight feerate{fee, 1};
|
||||
auto bottom_tx = graph->AddTransaction(feerate);
|
||||
TxGraph::Ref bottom_tx;
|
||||
graph->AddTransaction(bottom_tx, feerate);
|
||||
// Determine the number of dependencies this transaction will have.
|
||||
int deps = std::min<int>(NUM_DEPS_PER_BOTTOM_TX, top_components.size());
|
||||
for (int dep = 0; dep < deps; ++dep) {
|
||||
|
||||
Reference in New Issue
Block a user