|
1 | 1 | // c2pool-dgb — DigiByte Scrypt-only (V36) p2pool node entry point. |
2 | 2 | // |
3 | | -// SLICE #4 (Option B): genuinely minimal COMPILING SKELETON. This wires the |
4 | | -// CMake c2pool-dgb target so the binary builds + links off master; it does |
5 | | -// NOT yet run a node. The embedded-daemon + pool/sharechain body is M3 / |
6 | | -// Phase B (DGB = PORT-not-activation; Phase A p2p+mempool already landed under |
7 | | -// impl/dgb/coin/). When the pool-pillars node.cpp lands it replaces the |
8 | | -// skeleton via a clean dgb-only re-cut off master. |
| 3 | +// Wires the real dgb sharechain/pool TU (pool pillars + score path, ported from |
| 4 | +// LTC under impl/dgb/ across PRs #112/#113/#115/#121/#129/#131/#132/#134) into |
| 5 | +// the c2pool-dgb executable. This is the exe-wire slice: it replaces the |
| 6 | +// slice-#4 skeleton entry (dgb::run_skeleton/network_summary, removed when #134 |
| 7 | +// dropped the real node.cpp in) and drives the LIVE chain-score path at |
| 8 | +// startup, so the coin smoke gate exercises share_tracker::score() rather than |
| 9 | +// merely linking it. node.cpp (the concrete dgb::NodeImpl) is compiled into the |
| 10 | +// target so the real node TU links; its full run-loop (NodeBridge over the |
| 11 | +// embedded digibyted P2P + Stratum) is a later Phase B slice — dgb::NodeImpl is |
| 12 | +// abstract (ICommunicator::handle is supplied by the NodeBridge wrapper), so a |
| 13 | +// bare node is not stood up here. The score path lives on dgb::ShareTracker, |
| 14 | +// which we drive directly (header-only, no network / no LevelDB). |
9 | 15 | // |
10 | 16 | // V36 scope: Scrypt blocks validated; the other 4 DGB algos (SHA256d, Skein, |
11 | | -// Qubit, Odocrypt) are accept-by-continuity / ignored — full 5-algo support |
12 | | -// is V37. Compatibility target: frstrtr/p2pool-merged-v36 (share format, |
13 | | -// sharechain rules, PPLNS, Stratum, block submission). See |
14 | | -// c2pool-dgb-embedded-impl-plan.md (frstrtr/the docs/v36). |
15 | | -// |
16 | | -// Mirrors src/c2pool/main_btc.cpp's target shape, pruned to a stub entry. |
| 17 | +// Qubit, Odocrypt) are accept-by-continuity / ignored — full 5-algo support is |
| 18 | +// V37. Conformance oracle: frstrtr/p2pool-dgb-scrypt (DGB-Scrypt standalone |
| 19 | +// parent; merged-v36 byte-compat WAIVED for DGB per operator 2026-06-17). |
| 20 | +// CoinParams are oracle-sourced via dgb::make_coin_params (no hardcoded bytes). |
| 21 | +// Mirrors src/c2pool/main_btc.cpp's target shape. |
17 | 22 |
|
18 | 23 | #include <impl/dgb/node.hpp> |
19 | 24 |
|
| 25 | +#include <cstdint> |
20 | 26 | #include <cstring> |
21 | 27 | #include <iostream> |
| 28 | +#include <string> |
22 | 29 |
|
23 | 30 | #ifndef C2POOL_VERSION |
24 | 31 | #define C2POOL_VERSION "dev" |
25 | 32 | #endif |
26 | 33 |
|
27 | 34 | namespace { |
28 | 35 |
|
29 | | -void print_banner(const char* argv0) |
| 36 | +// Live network summary sourced from the oracle-populated CoinParams |
| 37 | +// (make_coin_params) — never a hardcoded string. These are the exact constants |
| 38 | +// the sharechain score() consumes (block_period etc.). |
| 39 | +std::string network_summary(const core::CoinParams& p) |
| 40 | +{ |
| 41 | + return "DigiByte (Scrypt-only) — identifier=" + p.active_identifier_hex() |
| 42 | + + " prefix=" + p.active_prefix_hex() |
| 43 | + + " block_period=" + std::to_string(p.block_period) + "s" |
| 44 | + + " share_period=" + std::to_string(p.share_period) + "s" |
| 45 | + + " chain_length=" + std::to_string(p.chain_length); |
| 46 | +} |
| 47 | + |
| 48 | +void print_banner(const char* argv0, const core::CoinParams& p) |
30 | 49 | { |
31 | 50 | std::cout |
32 | 51 | << "c2pool-dgb " << C2POOL_VERSION << " — DigiByte Scrypt-only (V36)\n\n" |
33 | | - << "Usage: " << argv0 << " [--version] [--help]\n\n" |
34 | | - << "Status: skeleton (slice #4). The node run-loop (embedded daemon +\n" |
35 | | - << " pool pillars) lands in M3 / Phase B.\n" |
36 | | - << "Network: " << dgb::network_summary() << "\n"; |
| 52 | + << "Usage: " << argv0 << " [--version] [--help] [--selftest]\n\n" |
| 53 | + << "Status: pool/sharechain pillars live (Phase B). The embedded-daemon\n" |
| 54 | + << " run-loop (digibyted P2P + Stratum) lands in a later slice;\n" |
| 55 | + << " external digibyted RPC stays as a fallback.\n" |
| 56 | + << "Network: " << network_summary(p) << "\n"; |
| 57 | +} |
| 58 | + |
| 59 | +// Drive the LIVE chain-score path: dgb::ShareTracker::score() derives time_span |
| 60 | +// from CoinParams::block_period (PR #132) and total_work from the verified |
| 61 | +// chain. On an empty verified set score() takes its short-chain early-return, |
| 62 | +// but the call EXECUTES the real score() body compiled from the #132/#134 |
| 63 | +// sharechain TU (not just links it) and reports the oracle block_period it |
| 64 | +// consumes. The deep block_period multiply (time_span = confirmations * |
| 65 | +// block_period) runs once a verified chain >= chain_length exists — exercised |
| 66 | +// by the Phase B share fixtures, not standable-up in a startup smoke. |
| 67 | +int run_selftest(const core::CoinParams& params) |
| 68 | +{ |
| 69 | + dgb::ShareTracker tracker; |
| 70 | + tracker.m_params = ¶ms; // wiring NodeImpl does at ctor time |
| 71 | + |
| 72 | + // No embedded daemon wired here → block height is "unknown" (0), which |
| 73 | + // routes score() through its 1e6-confirmation * block_period fallback. |
| 74 | + auto block_rel_height = [](uint256) -> std::int32_t { return 0; }; |
| 75 | + |
| 76 | + auto s = tracker.score(uint256::ZERO, block_rel_height); |
| 77 | + std::cout << "[selftest] live dgb::ShareTracker constructed; score() driven\n" |
| 78 | + << "[selftest] score(ZERO) -> chain_len=" << s.chain_len |
| 79 | + << " hashrate=" << (s.hashrate.IsNull() ? std::string("0") |
| 80 | + : s.hashrate.GetHex()) << "\n" |
| 81 | + << "[selftest] time_span basis block_period=" << params.block_period |
| 82 | + << "s (oracle PARENT.BLOCK_PERIOD, #132 SSOT)\n" |
| 83 | + << "[selftest] OK\n"; |
| 84 | + return 0; |
37 | 85 | } |
38 | 86 |
|
39 | 87 | } // namespace |
40 | 88 |
|
41 | 89 | int main(int argc, char** argv) |
42 | 90 | { |
| 91 | + bool want_help = false; |
| 92 | + bool want_selftest = false; |
43 | 93 | for (int i = 1; i < argc; ++i) { |
44 | 94 | if (std::strcmp(argv[i], "--version") == 0) { |
45 | 95 | std::cout << "c2pool-dgb " << C2POOL_VERSION << "\n"; |
46 | 96 | return 0; |
47 | 97 | } |
48 | | - if (std::strcmp(argv[i], "--help") == 0) { |
49 | | - print_banner(argv[0]); |
50 | | - return 0; |
51 | | - } |
| 98 | + if (std::strcmp(argv[i], "--help") == 0) want_help = true; |
| 99 | + if (std::strcmp(argv[i], "--selftest") == 0) want_selftest = true; |
52 | 100 | } |
53 | 101 |
|
54 | | - print_banner(argv[0]); |
55 | | - return dgb::run_skeleton(); |
| 102 | + const core::CoinParams params = dgb::make_coin_params(/*testnet=*/false); |
| 103 | + print_banner(argv[0], params); |
| 104 | + |
| 105 | + if (want_help) |
| 106 | + return 0; |
| 107 | + |
| 108 | + // --selftest, or a bare invocation (no run-loop yet): drive the live score |
| 109 | + // path so the binary exercises real consensus code, then exit cleanly. |
| 110 | + (void)want_selftest; |
| 111 | + return run_selftest(params); |
56 | 112 | } |
0 commit comments