Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/c2pool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,15 @@ add_executable(c2pool-bch
${CMAKE_SOURCE_DIR}/src/impl/bch/coin/p2p_node.cpp
${CMAKE_SOURCE_DIR}/src/impl/bch/coin/coin_node.cpp
${CMAKE_SOURCE_DIR}/src/impl/bch/coin/rpc.cpp
# M5 pool-node body TUs: NodeImpl out-of-line methods (node.cpp) + the two
# p2pool p2p protocol dispatchers (Legacy/Actual handle_message_* family) +
# the stratum work source. These define the previously-undefined NodeImpl::
# and protocol symbols so the --pool path LINKS. Per-coin isolation holds
# (src/impl/bch only); compiled directly into the target like the coin TUs.
${CMAKE_SOURCE_DIR}/src/impl/bch/node.cpp
${CMAKE_SOURCE_DIR}/src/impl/bch/protocol_actual.cpp
${CMAKE_SOURCE_DIR}/src/impl/bch/protocol_legacy.cpp
${CMAKE_SOURCE_DIR}/src/impl/bch/stratum/work_source.cpp
)
target_compile_definitions(c2pool-bch PRIVATE C2POOL_VERSION="${C2POOL_GIT_VERSION}")
# --ibd RUN-LOOP slice (integrator 2026-06-18): the read-only headers-first IBD
Expand Down
5 changes: 3 additions & 2 deletions src/impl/bch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
# TODO(M3): add_library(impl_bch ...) sources, link bitcoin_family shared base,
# wire embedded BCHN daemon slice under daemon/. Stub only at M2.
if(COIN_BCH)
message(STATUS "c2pool: BCH coin module enabled (skeleton)")
# add_subdirectory(coin)
message(STATUS "c2pool: BCH coin module enabled")
add_subdirectory(coin)
add_subdirectory(stratum)
# add_subdirectory(daemon)
add_subdirectory(test)
endif()
40 changes: 40 additions & 0 deletions src/impl/bch/coin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

# bch::coin library — c2pool-bch coin module (V36). Mirrors src/impl/btc/coin.
# Built when -DCOIN_BCH=ON via the parent add_subdirectory(coin).
# BCH-specific: SHA256d (BTC PoW family), NO SegWit, CashTokens transparent,
# ABLA dynamic block-size, ASERT DAA. Embedded BCHN daemon body lives here.

set(bch_coin_impl
rpc_data.hpp
rpc.hpp rpc.cpp
p2p_connection.hpp p2p_connection.cpp
p2p_node.cpp p2p_node.hpp
p2p_messages.hpp
node.hpp
coin_node.hpp coin_node.cpp
)

set(bch_coin_interface
txidcache.hpp
node_interface.hpp
block.hpp
transaction.hpp transaction.cpp
header_chain.hpp
mempool.hpp
template_builder.hpp
)

# BCH-specific consensus + embedded-daemon headers (header-only at this slice).
set(bch_coin_bchn
abla.hpp abla_block_feed.hpp abla_runtime.hpp abla_tracker.hpp
asert.hpp softfork_check.hpp
merkle.hpp cashaddr.hpp regtest_block.hpp
header_sync.hpp block_download.hpp block_connector.hpp
compact_blocks.hpp block_broadcast_guard.hpp
bchn_anchor_record.hpp chain_seeds.hpp
embedded_daemon.hpp
)

add_library(bch_coin ${bch_coin_interface} ${bch_coin_impl} ${bch_coin_bchn})

target_link_libraries(bch_coin core nlohmann_json::nlohmann_json)
2 changes: 1 addition & 1 deletion src/impl/bch/coin/embedded_daemon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class EmbeddedDaemon {
/// EmbeddedCoinNode::getwork() is the live in-process work source.
void run() {
m_chain.init(); // load genesis / fast-start checkpoint (network-free)
m_node.run(); // init_rpc(): external BCHN-RPC fallback retained
m_node.run(/*embedded_primary=*/true); // init_rpc(): eager external GBT non-fatal (embedded-primary); RPC fallback retained
assemble(); // network-free seam + ABLA wiring (see below)
wire_chain_ingest(); // new_headers --> HeaderChain (advances synced height)
pin_cold_start_anchor(); // operator-APPROVED VM300 anchor (decisions@ 2026-06-18); floor-equivalent
Expand Down
29 changes: 24 additions & 5 deletions src/impl/bch/coin/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,30 @@ class Node : public bch::interfaces::Node
m_p2p->connect(m_config->coin()->m_p2p.address);
}

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

// work
work.set(m_rpc->getwork());
// work (eager prime from external RPC)
if (embedded_primary) {
try {
work.set(m_rpc->getwork());
} catch (const std::exception& e) {
LOG_WARNING << "[EMB-BCH] init_rpc: external BCHN getwork() unavailable"
" at bring-up (" << e.what() << "); embedded-primary ->"
" deferring to embedded work source, RPC retained as"
" fallback sink.";
}
} else {
work.set(m_rpc->getwork());
}
}

public:
Expand All @@ -70,10 +87,12 @@ class Node : public bch::interfaces::Node
{
}

void run()
// embedded_primary defaults false: an external-RPC-as-work-source config still
// hard-fails on a dead RPC at bring-up. The embedded daemon passes true.
void run(bool embedded_primary = false)
{
// RPC
init_rpc();
init_rpc(embedded_primary);
}

/// Start P2P connection to coin daemon for fast block relay.
Expand Down
Loading
Loading