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
27 changes: 27 additions & 0 deletions src/c2pool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,33 @@ target_link_libraries(c2pool-btc
${Boost_LIBRARIES}
)

# c2pool-dgb: DigiByte Scrypt-only (V36) — slice #4 minimal COMPILING SKELETON.
# Mirrors the c2pool-btc add_executable shape, pruned to a stub entry. The body
# (embedded daemon + pool pillars) is M3/Phase B; this target only proves the
# binary builds + links off master. It compiles impl/dgb/node.cpp directly
# rather than linking a dgb / dgb_coin / impl_dgb lib on purpose: the top-level
# OBJECT-lib registration of src/impl/dgb is ci-steward's convention PR and is
# intentionally NOT raced here. The skeleton reads only header constexpr
# constants from impl/dgb/config_{coin,pool}.hpp; those headers #include
# core/netaddress.hpp, which #includes <yaml-cpp/yaml.h>. So the target needs
# yaml-cpp's INCLUDE DIR to compile — but NOT core's symbols: it never
# instantiates the Fileconfig-derived configs nor calls any core function.
# Linking the `core` library instead would drag in core/web_server.o +
# stratum_server.o, which reference merged/payout/hashrate/ltc symbols (the
# self-link tangle that forces c2pool-btc to drag in ltc/payout/merged) and
# would pull Phase B forward. We therefore add ONLY yaml-cpp (header path).
# Link deps stay at yaml-cpp + json + Boost until Phase B.
add_executable(c2pool-dgb
main_dgb.cpp
${CMAKE_SOURCE_DIR}/src/impl/dgb/node.cpp
)
target_compile_definitions(c2pool-dgb PRIVATE C2POOL_VERSION="${C2POOL_GIT_VERSION}")
target_link_libraries(c2pool-dgb
yaml-cpp::yaml-cpp # include dir only: config_{coin,pool}.hpp -> core/netaddress.hpp -> <yaml-cpp/yaml.h>
nlohmann_json::nlohmann_json
${Boost_LIBRARIES}
)

# Windows: Boost.Asio requires Winsock libraries; /bigobj for large translation units
if(WIN32)
target_link_libraries(c2pool ws2_32 mswsock bcrypt dbghelp)
Expand Down
56 changes: 56 additions & 0 deletions src/c2pool/main_dgb.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// c2pool-dgb — DigiByte Scrypt-only (V36) p2pool node entry point.
//
// SLICE #4 (Option B): genuinely minimal COMPILING SKELETON. This wires the
// CMake c2pool-dgb target so the binary builds + links off master; it does
// NOT yet run a node. The embedded-daemon + pool/sharechain body is M3 /
// Phase B (DGB = PORT-not-activation; Phase A p2p+mempool already landed under
// impl/dgb/coin/). When the pool-pillars node.cpp lands it replaces the
// skeleton via a clean dgb-only re-cut off master.
//
// V36 scope: Scrypt blocks validated; the other 4 DGB algos (SHA256d, Skein,
// Qubit, Odocrypt) are accept-by-continuity / ignored — full 5-algo support
// is V37. Compatibility target: frstrtr/p2pool-merged-v36 (share format,
// sharechain rules, PPLNS, Stratum, block submission). See
// c2pool-dgb-embedded-impl-plan.md (frstrtr/the docs/v36).
//
// Mirrors src/c2pool/main_btc.cpp's target shape, pruned to a stub entry.

#include <impl/dgb/node.hpp>

#include <cstring>
#include <iostream>

#ifndef C2POOL_VERSION
#define C2POOL_VERSION "dev"
#endif

namespace {

void print_banner(const char* argv0)
{
std::cout
<< "c2pool-dgb " << C2POOL_VERSION << " — DigiByte Scrypt-only (V36)\n\n"
<< "Usage: " << argv0 << " [--version] [--help]\n\n"
<< "Status: skeleton (slice #4). The node run-loop (embedded daemon +\n"
<< " pool pillars) lands in M3 / Phase B.\n"
<< "Network: " << dgb::network_summary() << "\n";
}

} // namespace

int main(int argc, char** argv)
{
for (int i = 1; i < argc; ++i) {
if (std::strcmp(argv[i], "--version") == 0) {
std::cout << "c2pool-dgb " << C2POOL_VERSION << "\n";
return 0;
}
if (std::strcmp(argv[i], "--help") == 0) {
print_banner(argv[0]);
return 0;
}
}

print_banner(argv[0]);
return dgb::run_skeleton();
}
193 changes: 193 additions & 0 deletions src/impl/dgb/messages.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
#pragma once
// V36 DGB-Scrypt pool wire-message layer — namespace-only divergence from
// src/impl/ltc/messages.hpp; message format byte-parity with p2pool-merged-v36.

#include "coin/block.hpp"
#include "coin/transaction.hpp"

#include <string>

#include <core/message.hpp>
#include <core/message_macro.hpp>
#include <sharechain/share.hpp>

namespace dgb
{

// message_version
BEGIN_MESSAGE(version)
MESSAGE_FIELDS
(
(uint32_t, m_version),
(uint64_t, m_services),
(addr_t , m_addr_to),
(addr_t, m_addr_from),
(uint64_t, m_nonce),
(std::string, m_subversion),
(uint32_t, m_mode), //# always 1 for legacy compatibility
(uint256, m_best_share)
)
{
READWRITE(obj.m_version, obj.m_services, obj.m_addr_to, obj.m_addr_from, obj.m_nonce, obj.m_subversion, obj.m_mode, obj.m_best_share);
}
END_MESSAGE()

// message_ping
BEGIN_MESSAGE(ping)
WITHOUT_MESSAGE_FIELDS() { }
END_MESSAGE()

// message_addrme
BEGIN_MESSAGE(addrme)
MESSAGE_FIELDS
(
(uint16_t, m_port)
)
{
READWRITE(obj.m_port);
}
END_MESSAGE()

// message_getaddrs
BEGIN_MESSAGE(getaddrs)
MESSAGE_FIELDS
(
(uint32_t, m_count)
)
{
READWRITE(obj.m_count);
}
END_MESSAGE()

// message_addrs
BEGIN_MESSAGE(addrs)
MESSAGE_FIELDS
(
(std::vector<addr_record_t>, m_addrs)
)
{
READWRITE(obj.m_addrs);
}
END_MESSAGE()

// message_shares
BEGIN_MESSAGE(shares)
MESSAGE_FIELDS
(
(std::vector<chain::RawShare>, m_shares)
)
{
READWRITE(obj.m_shares);
}
END_MESSAGE()

// message_sharereq
BEGIN_MESSAGE(sharereq)
MESSAGE_FIELDS
(
(uint256, m_id),
(std::vector<uint256>, m_hashes),
(uint64_t, m_parents),
(std::vector<uint256>, m_stops)
)
{
READWRITE(obj.m_id, obj.m_hashes, VarInt(obj.m_parents), obj.m_stops);
}
END_MESSAGE()

enum ShareReplyResult
{
good = 0,
too_long = 1,
unk2 = 2,
unk3 = 3,
unk4 = 4,
unk5 = 5,
unk6 = 6
};

// message_sharereply
BEGIN_MESSAGE(sharereply)
MESSAGE_FIELDS
(
(uint256, m_id),
(ShareReplyResult, m_result),
(std::vector<chain::RawShare>, m_shares)
)
{
READWRITE(obj.m_id, Using<EnumType<CompactFormat>>(obj.m_result), obj.m_shares);
}
END_MESSAGE()

// message_bestblock
BEGIN_MESSAGE(bestblock)
MESSAGE_FIELDS
(
(coin::BlockHeaderType, m_header)
)
{
READWRITE(obj.m_header);
}
END_MESSAGE()

// message_have_tx
BEGIN_MESSAGE(have_tx)
MESSAGE_FIELDS
(
(std::vector<uint256>, m_tx_hashes)
)
{
READWRITE(obj.m_tx_hashes);
}
END_MESSAGE()

// message_losing_tx
BEGIN_MESSAGE(losing_tx)
MESSAGE_FIELDS
(
(std::vector<uint256>, m_tx_hashes)
)
{
READWRITE(obj.m_tx_hashes);
}
END_MESSAGE()

// message_forget_tx
BEGIN_MESSAGE(forget_tx)
MESSAGE_FIELDS
(
(std::vector<uint256>, m_tx_hashes)
)
{
READWRITE(obj.m_tx_hashes);
}
END_MESSAGE()

// message_remember_tx
BEGIN_MESSAGE(remember_tx)
MESSAGE_FIELDS
(
(std::vector<uint256>, m_tx_hashes),
(std::vector<coin::MutableTransaction>, m_txs)
)
{
READWRITE(obj.m_tx_hashes, coin::TX_WITH_WITNESS(obj.m_txs));
}
END_MESSAGE()

using Handler = MessageHandler<
message_ping,
message_addrme,
message_getaddrs,
message_addrs,
message_shares,
message_sharereq,
message_sharereply,
message_bestblock,
message_have_tx,
message_losing_tx,
message_forget_tx,
message_remember_tx
>;

} // namespace dgb
41 changes: 41 additions & 0 deletions src/impl/dgb/node.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "node.hpp"

#include <string>

// c2pool-dgb node skeleton (slice #4, Option B).
//
// COMPILING SKELETON ONLY. The real embedded-daemon + pool/sharechain body
// (DensePPLNSWindow / PPLNS, p2p run-loop, template builder, broadcaster) is
// M3 / Phase B per the embedded-daemon roadmap: DGB is PORT-not-activation —
// Phase A p2p + mempool already landed under impl/dgb/coin/, and Phase B
// brings the pool pillars. When the pool-pillars node.cpp lands it REPLACES
// this file via a clean dgb-only re-cut off master; see
// c2pool-dgb-embedded-impl-plan.md (frstrtr/the docs/v36).
//
// Deliberately free of pool logic so c2pool-dgb LINKS today without dragging
// Phase B forward, instantiating the Fileconfig-derived config classes (whose
// load()/get_default() bodies are Phase B), or touching the shared
// bitcoin_family / DOGE-aux surface.

namespace dgb
{

// One-line summary of the DGB-Scrypt network this binary targets. Reads the
// compile-time constants from config_{coin,pool}.hpp (header-only) — no
// Fileconfig instantiation.
std::string network_summary()
{
return std::string("DigiByte Scrypt-only (V36) — ")
+ "pool_p2p_port=" + std::to_string(PoolConfig::P2P_PORT)
+ " coin_p2p_port=" + std::to_string(CoinParams::MAINNET_P2P_PORT)
+ " block_period=" + std::to_string(CoinParams::BLOCK_PERIOD) + "s"
+ " gbt_algo=" + std::string(CoinParams::GBT_ALGO);
}

// Skeleton entry point. Phase B replaces this with the real node run-loop.
int run_skeleton()
{
return 0;
}

} // namespace dgb
15 changes: 15 additions & 0 deletions src/impl/dgb/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "config_pool.hpp"
#include "config_coin.hpp"

#include <string>

// DGB Scrypt shares use the same format as LTC shares.
// The share type, validation logic, tracker, and protocol are shared.
// Only config_pool and config_coin differ between LTC and DGB networks.
Expand All @@ -27,4 +29,17 @@ namespace dgb
using PoolConfigType = dgb::PoolConfig;
using CoinParamsType = dgb::CoinParams;

// ---------------------------------------------------------------------------
// Skeleton entry points (slice #4, Option B). Defined in node.cpp.
// COMPILING SKELETON ONLY — the real node run-loop is M3 / Phase B.
// ---------------------------------------------------------------------------

// One-line summary of the DGB-Scrypt network from the header-only config
// constants (no Fileconfig instantiation).
std::string network_summary();

// Skeleton run entry. Returns a process exit code. Phase B replaces this with
// the embedded-daemon + pool/sharechain run-loop.
int run_skeleton();

} // namespace dgb
29 changes: 29 additions & 0 deletions src/impl/dgb/peer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#include "coin/transaction.hpp"

#include <chrono>
#include <set>
#include <optional>
#include <core/uint256.hpp>

namespace dgb
{

struct Peer
{
std::optional<uint32_t> m_other_version;
std::string m_other_subversion;
uint64_t m_other_services;
uint64_t m_nonce;
std::chrono::steady_clock::time_point m_connected_at{std::chrono::steady_clock::now()};

std::set<uint256> m_remote_txs; // hashes
// int32_t remote_remembered_txs_size = 0;

std::map<uint256, coin::Transaction> m_remembered_txs;
// int32_t remembered_txs_size = 0;
// const int32_t max_remembered_txs_size = 25000000;
};

}; // namespace dgb
Loading
Loading