Skip to content

dgb(#82): run-loop spine — io_context + graceful signal_set shutdown (--run) - #182

Merged
frstrtr merged 3 commits into
masterfrom
dgb/run-loop-skeleton
Jun 19, 2026
Merged

dgb(#82): run-loop spine — io_context + graceful signal_set shutdown (--run)#182
frstrtr merged 3 commits into
masterfrom
dgb/run-loop-skeleton

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 19, 2026

Copy link
Copy Markdown
Owner

What

Stands up the run-loop spine in main_dgb.cpp behind a new --run flag: a boost::asio::io_context + explicit graceful shutdown from signal_set(SIGINT, SIGTERM), mirroring main_btc.cpps teardown contract.

Why (#82)

This is the lifecycle every node subsystem (sharechain peer dgb::Node, embedded digibyted P2P, Stratum acceptor) and the won-block dispatch handler hang off. The #82 connecting tissue is landed across #163/#166/#167/#173/#174/#176/#177/#179; the remaining closer is binding it into a live run-loop. Standing the spine up first keeps the next increments — node/Config construction (opens LevelDB), P2P listen, Stratum, and the m_on_block_found -> reconstruct_won_block -> broadcast_won_block binding — each build-verifiable rather than landing a large unverified port in one step.

Scope / preserved

  • --selftest / bare invocation unchanged (live ShareTracker::score() path, block_period=75s SSOT).
  • External digibyted RPC fallback posture preserved.
  • Single-coin: only src/c2pool/main_dgb.cpp touched. No shared base / CMake / build.yml change.

Verification

  • Build: c2pool-dgb links EXIT=0 (-DCOIN_DGB=ON).
  • Smoke --selftest: OK (oracle identifier 4b62545b1a631afe, block_period=75s).
  • Smoke --run: spine up, SIGINT -> graceful shutdown -> clean exit 0.

Next stacked slice

Construct dgb::Config + dgb::Node(&ioc,&config), listen on the sharechain P2P port, stand up Stratum, and bind make_on_block_found(...) into m_on_block_found (closes #82 won-block-reaches-network).

HOLD merge.

@frstrtr
frstrtr force-pushed the dgb/run-loop-skeleton branch from f9dd2fd to b464ce0 Compare June 19, 2026 07:54
frstrtr added a commit that referenced this pull request Jun 19, 2026
…RPC arm wired

Stacks on the run-loop (#182 spine + node-construct) and the DGBWorkSource
4a skeleton (#186): closes the SEAM both left for "stand the Stratum work
source up + bind the won-block broadcaster."

--run now constructs the miner-facing path on the run-loop io_context:
  - c2pool::dgb::HeaderChain + dgb::coin::Mempool (MVP-unwired this slice —
    the 4a work source returns default work; mining_submit low-diff-rejects
    via the 0.0 compute_share_difficulty sentinel BEFORE the broadcaster, so
    no garbage block is ever emitted)
  - dgb::coin::CoinNode(nullptr,nullptr) + a SubmitBlockFn bridging
    block_bytes -> hex -> submit_block_hex (rpc.cpp:387, REAL not a stub):
    the submitblock-RPC arm of the #82 dual-path broadcaster. has_rpc()==false
    => returns false LOUDLY (the #163 seam guard: no silent drop).
  - dgb::stratum::DGBWorkSource + core::StratumServer, gated on a new
    --stratum [HOST:]PORT flag (mirrors main_btc.cpp). Acceptor lifecycle is
    wired into the signal_set handler: stratum stop() runs BEFORE ioc.stop()
    so live miner sessions close cleanly.

CMake: link c2pool-dgb against dgb_stratum. Single-coin (no bitcoin_family /
src/core touch); core::StratumServer consumed, not modified. No -DAUX_DOGE.

Remaining for the #82 closer (NEXT slice): the embedded P2P-relay arm
(m_on_block_found -> reconstruct_won_block -> broadcast_won_block) needs the
reconstructor stack (#163/#166/#167/#177), HELD off master. Two-arm
independent broadcast evidence captured once both arms are live.

Build EXIT=0; --run --stratum 127.0.0.1:5022 smoke: StratumServer started,
sharechain peer on 5024, SIGINT -> ordered graceful shutdown (stratum stop
then clean exit), EXIT=0.
@frstrtr
frstrtr force-pushed the dgb/run-loop-skeleton branch from b464ce0 to 84a6c9d Compare June 19, 2026 08:04
frstrtr added 3 commits June 19, 2026 11:04
…(--run)

Stand up the run-loop spine in main_dgb.cpp behind a new --run flag: a
boost::asio::io_context plus an explicit graceful shutdown driven from
signal_set(SIGINT, SIGTERM), mirroring main_btc.cpp s teardown contract.

This is the lifecycle every node subsystem (sharechain peer dgb::Node,
embedded digibyted P2P, Stratum acceptor) and the #82 won-block dispatch
handler hangs off. Standing the spine up first keeps the next increments
(node/Config construction over LevelDB, P2P listen, Stratum, and the
m_on_block_found -> reconstruct_won_block -> broadcast_won_block binding
landed across #163/#166/#167/#173/#174/#176/#177/#179) build-verifiable
rather than landing a large unverified port in one step.

--selftest / bare invocation unchanged (live ShareTracker::score() path).
External digibyted RPC fallback posture preserved.

Build: c2pool-dgb links EXIT=0 (-DCOIN_DGB=ON). Smoke: --selftest OK
(block_period=75s SSOT); --run spine up, SIGINT -> clean shutdown exit 0.
…run)

Second stacked run-loop slice. main_dgb.cpp --run now constructs the real
dgb::Config + dgb::Node (pool::NodeBridge<NodeImpl, Legacy, Actual>) on the
spine io_context, opens the sharechain LevelDB, and binds the P2P listener on
PoolConfig::P2P_PORT (5024) — the sharechain peer is live, not just the
io_context spine.

Config is set directly from the p2pool-dgb-scrypt oracle constants (PREFIX
1c0553f2..., IDENTIFIER 4b62545b...), skipping Config::init() yaml load, the
same contract main_btc.cpp uses. DEFAULT_BOOTSTRAP_HOSTS is empty until DGB
p2pool nodes come online, so there are no outbound seeds to dial this slice;
the node listens and waits for inbound peers. The per-coin net dir is digibyte/
(bucket-1 isolation).

Constructing the node pulls BaseNode::connected (boost::log) and the NodeImpl
TU, so the c2pool-dgb exe must link the real dgb pool runtime, not just the
header-only score path. Wire the exe to link the dgb OBJECT lib + dgb_coin +
core/pool/sharechain/storage base, mirroring the c2pool-btc link set;
c2pool_merged_mining is pulled for symbol resolution of the core web_server
tangle only (same as c2pool-btc) and does NOT enable -DAUX_DOGE — DGB default
build stays standalone. Only the c2pool-dgb target stanza changes; per-coin
isolation holds.

Build EXIT=0. Smoke: --run binds 0.0.0.0:5024 (ss-confirmed), SIGINT ->
graceful shutdown -> clean exit 0, LevelDB closed cleanly; --selftest still
drives the live score() path; --version OK.

SEAM (next slice): stand up the Stratum work source + bind
make_on_block_found(reconstruct_won_block, p2p_sink) into m_on_block_found
to close the #82 embedded P2P relay path (submitblock RPC fallback at
rpc.cpp:387 is already real, not a stub).
…ks c2pool-dgb

The run-loop slice switched c2pool-dgb to link the dgb and dgb_coin OBJECT
libs, but both were defined only inside if(COIN_DGB). The coin-matrix CI job
configures without -DCOIN_DGB, so the targets were undefined and CMake emitted
raw -ldgb/-ldgb_coin, failing the link (cannot find -ldgb). Mirror btc/ltc,
which define their per-coin libs unconditionally; keep only the test subtree
behind COIN_DGB (build.yml sets the flag and builds those targets).

Verified: fresh configure with COIN_DGB=OFF builds + links c2pool-dgb and
--help smokes clean (EXIT=0).
@frstrtr
frstrtr force-pushed the dgb/run-loop-skeleton branch from c1cdc33 to 55dbd05 Compare June 19, 2026 11:07
frstrtr added a commit that referenced this pull request Jun 19, 2026
…RPC arm wired

Stacks on the run-loop (#182 spine + node-construct) and the DGBWorkSource
4a skeleton (#186): closes the SEAM both left for "stand the Stratum work
source up + bind the won-block broadcaster."

--run now constructs the miner-facing path on the run-loop io_context:
  - c2pool::dgb::HeaderChain + dgb::coin::Mempool (MVP-unwired this slice —
    the 4a work source returns default work; mining_submit low-diff-rejects
    via the 0.0 compute_share_difficulty sentinel BEFORE the broadcaster, so
    no garbage block is ever emitted)
  - dgb::coin::CoinNode(nullptr,nullptr) + a SubmitBlockFn bridging
    block_bytes -> hex -> submit_block_hex (rpc.cpp:387, REAL not a stub):
    the submitblock-RPC arm of the #82 dual-path broadcaster. has_rpc()==false
    => returns false LOUDLY (the #163 seam guard: no silent drop).
  - dgb::stratum::DGBWorkSource + core::StratumServer, gated on a new
    --stratum [HOST:]PORT flag (mirrors main_btc.cpp). Acceptor lifecycle is
    wired into the signal_set handler: stratum stop() runs BEFORE ioc.stop()
    so live miner sessions close cleanly.

CMake: link c2pool-dgb against dgb_stratum. Single-coin (no bitcoin_family /
src/core touch); core::StratumServer consumed, not modified. No -DAUX_DOGE.

Remaining for the #82 closer (NEXT slice): the embedded P2P-relay arm
(m_on_block_found -> reconstruct_won_block -> broadcast_won_block) needs the
reconstructor stack (#163/#166/#167/#177), HELD off master. Two-arm
independent broadcast evidence captured once both arms are live.

Build EXIT=0; --run --stratum 127.0.0.1:5022 smoke: StratumServer started,
sharechain peer on 5024, SIGINT -> ordered graceful shutdown (stratum stop
then clean exit), EXIT=0.
@frstrtr
frstrtr merged commit 5b4e67c into master Jun 19, 2026
19 checks passed
@frstrtr
frstrtr deleted the dgb/run-loop-skeleton branch June 19, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant