Skip to content

Commit b11a8aa

Browse files
committed
bch(m5): link pool-node TUs into c2pool-bch executable
Register node.cpp and the BCHWorkSource/protocol dispatch TUs in the c2pool-bch add_executable stanza so NodeImpl:: symbols resolve, closing the --pool/--stratum link gap. Additive single-coin CMake stanza; no shared-base or peer-coin build changes. share_tracker.hpp carries the pool-node share-write integration.
1 parent 5cf3345 commit b11a8aa

5 files changed

Lines changed: 3761 additions & 7 deletions

File tree

src/c2pool/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,15 @@ add_executable(c2pool-bch
238238
${CMAKE_SOURCE_DIR}/src/impl/bch/coin/p2p_node.cpp
239239
${CMAKE_SOURCE_DIR}/src/impl/bch/coin/coin_node.cpp
240240
${CMAKE_SOURCE_DIR}/src/impl/bch/coin/rpc.cpp
241+
# M5 pool-node body TUs: NodeImpl out-of-line methods (node.cpp) + the two
242+
# p2pool p2p protocol dispatchers (Legacy/Actual handle_message_* family) +
243+
# the stratum work source. These define the previously-undefined NodeImpl::
244+
# and protocol symbols so the --pool path LINKS. Per-coin isolation holds
245+
# (src/impl/bch only); compiled directly into the target like the coin TUs.
246+
${CMAKE_SOURCE_DIR}/src/impl/bch/node.cpp
247+
${CMAKE_SOURCE_DIR}/src/impl/bch/protocol_actual.cpp
248+
${CMAKE_SOURCE_DIR}/src/impl/bch/protocol_legacy.cpp
249+
${CMAKE_SOURCE_DIR}/src/impl/bch/stratum/work_source.cpp
241250
)
242251
target_compile_definitions(c2pool-bch PRIVATE C2POOL_VERSION="${C2POOL_GIT_VERSION}")
243252
# --ibd RUN-LOOP slice (integrator 2026-06-18): the read-only headers-first IBD

src/impl/bch/coin/embedded_daemon.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class EmbeddedDaemon {
100100
/// EmbeddedCoinNode::getwork() is the live in-process work source.
101101
void run() {
102102
m_chain.init(); // load genesis / fast-start checkpoint (network-free)
103-
m_node.run(); // init_rpc(): external BCHN-RPC fallback retained
103+
m_node.run(/*embedded_primary=*/true); // init_rpc(): eager external GBT non-fatal (embedded-primary); RPC fallback retained
104104
assemble(); // network-free seam + ABLA wiring (see below)
105105
wire_chain_ingest(); // new_headers --> HeaderChain (advances synced height)
106106
pin_cold_start_anchor(); // operator-APPROVED VM300 anchor (decisions@ 2026-06-18); floor-equivalent

src/impl/bch/coin/node.hpp

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,30 @@ class Node : public bch::interfaces::Node
5555
m_p2p->connect(m_config->coin()->m_p2p.address);
5656
}
5757

58-
void init_rpc()
58+
// embedded_primary: when the in-process embedded daemon is the PRIMARY work
59+
// source (v36 external_fallback invariant), a dead / 0-peer external BCHN that
60+
// cannot yet answer getblocktemplate must NOT abort bring-up -- the embedded
61+
// source provides work and the external RPC is only the fallback sink. When the
62+
// external RPC IS the work source (embedded_primary == false), a failure here
63+
// stays fatal exactly as before.
64+
void init_rpc(bool embedded_primary)
5965
{
6066
m_rpc = std::make_unique<NodeRPC>(m_context, this, m_config->m_testnet);
6167
m_rpc->connect(m_config->m_rpc.address, m_config->m_rpc.userpass);
6268

63-
// work
64-
work.set(m_rpc->getwork());
69+
// work (eager prime from external RPC)
70+
if (embedded_primary) {
71+
try {
72+
work.set(m_rpc->getwork());
73+
} catch (const std::exception& e) {
74+
LOG_WARNING << "[EMB-BCH] init_rpc: external BCHN getwork() unavailable"
75+
" at bring-up (" << e.what() << "); embedded-primary ->"
76+
" deferring to embedded work source, RPC retained as"
77+
" fallback sink.";
78+
}
79+
} else {
80+
work.set(m_rpc->getwork());
81+
}
6582
}
6683

6784
public:
@@ -70,10 +87,12 @@ class Node : public bch::interfaces::Node
7087
{
7188
}
7289

73-
void run()
90+
// embedded_primary defaults false: an external-RPC-as-work-source config still
91+
// hard-fails on a dead RPC at bring-up. The embedded daemon passes true.
92+
void run(bool embedded_primary = false)
7493
{
7594
// RPC
76-
init_rpc();
95+
init_rpc(embedded_primary);
7796
}
7897

7998
/// Start P2P connection to coin daemon for fast block relay.

0 commit comments

Comments
 (0)