Skip to content

Commit 6f7ee0a

Browse files
authored
Merge pull request #237 from frstrtr/dgb/embedded-coinnode-prod-wire
dgb: wire EmbeddedCoinNode into production CoinNode work source
2 parents f1be5e6 + 62da0da commit 6f7ee0a

1 file changed

Lines changed: 28 additions & 9 deletions

File tree

src/c2pool/main_dgb.cpp

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <impl/dgb/coin/header_chain.hpp>
3131
#include <impl/dgb/coin/mempool.hpp>
3232
#include <impl/dgb/coin/coin_node.hpp>
33+
#include <impl/dgb/coin/embedded_coin_node.hpp>
3334
#include <impl/dgb/coin/won_block_dispatch.hpp>
3435
#include <impl/dgb/stratum/work_source.hpp>
3536

@@ -186,14 +187,31 @@ int run_node(const core::CoinParams& params, bool testnet,
186187
// NodeImpl ctor opens ~/.c2pool/<net>/sharechain_leveldb and seeds the addr
187188
// store from m_bootstrap_addrs, so config must be populated BEFORE
188189
// construction (above).
189-
// CoinNode seam — the external-digibyted submitblock FALLBACK leg of the
190-
// #82 dual-path broadcaster, shared by BOTH the sharechain m_on_block_found
191-
// arm (just below) and the miner-facing Stratum arm (further below).
192-
// Declared BEFORE p2p_node so it OUTLIVES the tracker callback that captures
193-
// it. CoinNode(nullptr embedded, nullptr rpc) => has_rpc()==false =>
194-
// submit_block_hex returns false LOUDLY (the #163 seam guard: no silent
195-
// drop). Point a real NodeRPC at external digibyted here to light it up.
196-
dgb::coin::CoinNode coin_node(/*embedded=*/nullptr, /*rpc=*/nullptr);
190+
// §7b embedded chain — backs the in-process work source below and is
191+
// fed by the embedded P2P header ingest once that lands. Declared HERE
192+
// (ahead of coin_node) so EmbeddedCoinNode, which holds a HeaderChain&,
193+
// and coin_node, which holds the EmbeddedCoinNode*, both outlive the
194+
// tracker callback captured below. The DGBWorkSource further down holds
195+
// the same non-owning ref.
196+
c2pool::dgb::HeaderChain header_chain;
197+
198+
// Embedded in-process work source: assembles GBT-compatible templates
199+
// ENTIRELY from embedded chain state + the coin subsidy schedule (no
200+
// external digibyted). coinbasevalue resolves through the #207 ->
201+
// subsidy_func SSOT; transactions[]/bits are held back truthfully until
202+
// the embedded mempool + next-target source are plumbed.
203+
dgb::coin::EmbeddedCoinNode embedded_coin(header_chain, params.subsidy_func);
204+
205+
// CoinNode seam — embedded-preferred work source (embedded_coin) with the
206+
// external-digibyted submitblock FALLBACK leg of the #82 dual-path
207+
// broadcaster. Shared by BOTH the sharechain m_on_block_found arm (just
208+
// below) and the miner-facing Stratum arm (further below). Declared
209+
// BEFORE p2p_node so it OUTLIVES the tracker callback that captures it.
210+
// rpc=nullptr => has_rpc()==false => submit_block_hex returns false
211+
// LOUDLY (the #163 seam guard: no silent drop, INDEPENDENT of the
212+
// embedded source). Point a real NodeRPC at external digibyted here to
213+
// light the submit sink up.
214+
dgb::coin::CoinNode coin_node(/*embedded=*/&embedded_coin, /*rpc=*/nullptr);
197215

198216
dgb::Node p2p_node(&ioc, &config);
199217
p2p_node.set_target_outbound_peers(4);
@@ -245,7 +263,8 @@ int run_node(const core::CoinParams& params, bool testnet,
245263
// emitted — the standup proves the StratumServer<->IWorkSource wiring
246264
// end-to-end. Real work-gen / Scrypt share-validation land in 4b/4c.
247265
// This mirrors btc::stratum standing its skeleton wiring up first.
248-
c2pool::dgb::HeaderChain header_chain; // §7b chain, MVP-unwired (empty)
266+
// header_chain is declared above coin_node (it backs the EmbeddedCoinNode
267+
// work source); only the unwired Mempool is declared here.
249268
dgb::coin::Mempool mempool; // unwired (no UTXO/template feed yet)
250269

251270
// submitblock-RPC arm of the #82 dual-path broadcaster, driven from the

0 commit comments

Comments
 (0)