Skip to content

Commit 8c0f984

Browse files
committed
dgb(phase-b): feed stratum get_current_work_template from embedded mempool
Wire DGBWorkSource::get_current_work_template to select fee-sorted mempool transactions via the make_mempool_tx_source SSOT (BLOCK_MAX_WEIGHT cap), mirroring the embedded node path (#248). The selection shapes GBT transactions[] and its fee total folds into coinbasevalue through the #207 resolve_coinbase_value SSOT; the builder passes the array through verbatim. On the current empty embedded mempool the call yields an empty transactions[] and total_fees=0 -- byte-identical to the prior coinbase-only template. It lights up unchanged once the embedded P2P mempool feed populates the pool. DGB-tree only; shared modules untouched. dgb_share_test 26/26, block_assembly 8/8, mempool_ingest 5/5; c2pool-dgb links.
1 parent c9f59c5 commit 8c0f984

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

src/impl/dgb/stratum/work_source.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <impl/dgb/coin/embedded_coinbase_value.hpp>
2121
#include <impl/dgb/coin/dgb_block_algo.hpp>
2222
#include <impl/dgb/coin/template_builder.hpp>
23+
#include <impl/dgb/coin/embedded_tx_select.hpp> // make_mempool_tx_source (mempool -> GBT transactions[])
24+
#include <impl/dgb/config_pool.hpp> // dgb::PoolConfig::BLOCK_MAX_WEIGHT
2325
#include <impl/dgb/coin/hash_format.hpp>
2426
#include <impl/dgb/coin/scrypt_pow.hpp> // scrypt_pow_hash (DGB-Scrypt PoW SSOT)
2527
#include <impl/dgb/coin/submit_classify.hpp> // classify_submission (Stage-4d decision SSOT)
@@ -245,8 +247,20 @@ nlohmann::json DGBWorkSource::get_current_work_template() const
245247
// compose in later slices WITHOUT changing this SSOT call (a present GBT
246248
// coinbasevalue stays authoritative; fees add on top of subsidy).
247249
const uint32_t next_h = chain_.next_block_height();
250+
251+
// Phase B: feed the served template from the in-process embedded Mempool,
252+
// mirroring the embedded node path (#248, embedded_coin_node.hpp). The
253+
// make_mempool_tx_source SSOT selects fee-sorted txs up to BLOCK_MAX_WEIGHT
254+
// and shapes them into the GBT transactions[] form build_work_template passes
255+
// through verbatim; their fee total folds into coinbasevalue via the #207
256+
// resolve_coinbase_value SSOT (NOT added to the template). On today's empty
257+
// embedded mempool this yields an empty transactions[] and total_fees=0 --
258+
// byte-identical to the prior coinbase-only template; it lights up unchanged
259+
// once the embedded P2P mempool feed populates the pool.
260+
const dgb::coin::EmbeddedTxSelection tx_sel =
261+
dgb::coin::make_mempool_tx_source(mempool_, dgb::PoolConfig::BLOCK_MAX_WEIGHT)();
248262
const uint64_t coinbasevalue =
249-
coinbase_value(next_h, /*total_fees=*/0, /*gbt_coinbasevalue=*/std::nullopt);
263+
coinbase_value(next_h, /*total_fees=*/tx_sel.total_fees, /*gbt_coinbasevalue=*/std::nullopt);
250264

251265
// GBT-scaffold fields the embedded path can derive TRUTHFULLY from current
252266
// chain state, ahead of a full dgb::coin::TemplateBuilder port (M3 TODO):
@@ -260,9 +274,10 @@ nlohmann::json DGBWorkSource::get_current_work_template() const
260274
// mintime — median_time_past()+1 (#209 accessor): DGB Core's
261275
// ContextualCheckBlockHeader lower bound (nTime > MTP). An
262276
// empty chain returns INT64_MIN (unconstrained) -> emit 0.
263-
// transactions — empty array: embedded mempool tx SELECTION is not wired,
264-
// so no transactions are fabricated and fees stay 0
265-
// (consistent with the total_fees=0 coinbasevalue above).
277+
// transactions — fee-sorted mempool selection via make_mempool_tx_source
278+
// (BLOCK_MAX_WEIGHT cap), shaped into GBT {data,txid,hash,fee}
279+
// objects; their fee total folds into the coinbasevalue above
280+
// (#207 SSOT). Empty embedded mempool -> empty array, fees 0.
266281
//
267282
// previousblockhash — the tip block id. Emitted ONLY when the HeaderChain
268283
// carries a real tip hash (tip_hash() accessor): the
@@ -298,6 +313,7 @@ nlohmann::json DGBWorkSource::get_current_work_template() const
298313
in.coinbasevalue = coinbasevalue;
299314
in.median_time_past = chain_.median_time_past();
300315
in.curtime = static_cast<int64_t>(std::time(nullptr));
316+
in.transactions = tx_sel.transactions;
301317
if (auto th = chain_.tip_hash())
302318
in.previousblockhash = u256_be_display_hex(*th);
303319

0 commit comments

Comments
 (0)