@@ -249,6 +249,11 @@ int run_node(const core::CoinParams& params, bool testnet,
249249 // audited rather than silently dropped, and NO malformed block is emitted.
250250 // Assigned at setup (single-threaded, pre-ioc.run) — the only safe point to
251251 // touch tracker() off the compute thread.
252+ // Declared ahead of the m_on_block_found binding so the won-block P2P-relay
253+ // sink below can capture it. Constructed later only when --coin-daemon is
254+ // supplied (stays null otherwise -> sink no-ops, RPC fallback still fires).
255+ std::unique_ptr<dgb::coin::p2p::NodeP2P<dgb::Config>> coin_p2p;
256+
252257 p2p_node.tracker ().m_on_block_found = dgb::coin::make_on_block_found (
253258 /* reconstruct=*/ [](const uint256& share_hash)
254259 -> std::optional<std::pair<std::vector<unsigned char >, std::string>> {
@@ -257,7 +262,17 @@ int run_node(const core::CoinParams& params, bool testnet,
257262 " pending Phase B); not broadcast this build" << std::endl;
258263 return std::nullopt ;
259264 },
260- /* p2p_relay=*/ dgb::coin::P2pRelaySink{}, // no embedded P2P sink yet (guarded)
265+ /* p2p_relay=*/ [&ioc, &coin_p2p](const std::vector<unsigned char >& block_bytes) {
266+ // #82 PRIMARY arm: relay the won block over the embedded coin-daemon
267+ // P2P producer. The sink fires from the compute thread, so post the
268+ // peer write onto the io thread (NodeP2P is single-thread-confined).
269+ // No-op when --coin-daemon is absent (coin_p2p null) — the RPC
270+ // fallback below still fires (dual-path rule).
271+ if (!coin_p2p) return ;
272+ io::post (ioc, [&coin_p2p, bytes = block_bytes]() {
273+ if (coin_p2p) coin_p2p->submit_block_p2p_raw (bytes);
274+ });
275+ },
261276 /* seam=*/ &coin_node); // external-digibyted submitblock fallback
262277
263278 // ── #82 dual-path won-block CLOSER: miner-facing Stratum standup ───────
@@ -320,7 +335,6 @@ int run_node(const core::CoinParams& params, bool testnet,
320335 //
321336 // No behavior change when --coin-daemon is absent: coin_p2p stays null, the
322337 // consumer seam idles exactly as before this slice.
323- std::unique_ptr<dgb::coin::p2p::NodeP2P<dgb::Config>> coin_p2p;
324338 io::steady_timer coin_getheaders_timer (ioc);
325339 if (!coin_daemon.empty ()) {
326340 if (coin_magic.empty ())
0 commit comments