|
| 1 | +#pragma once |
| 2 | + |
| 3 | +// --------------------------------------------------------------------------- |
| 4 | +// ltc::coin::CoinNode -- concrete core::coin::ICoinNode for LTC (family-1 P2 |
| 5 | +// WorkView seam). This is the REFERENCE impl the btc::coin::CoinNode mirrors |
| 6 | +// (piece-5(c)); the control flow / sequencing here are the load-bearing part. |
| 7 | +// |
| 8 | +// m_embedded : CoinNodeInterface* -- EmbeddedCoinNode in-process source |
| 9 | +// m_rpc : NodeRPC* -- external coin-RPC client |
| 10 | +// work : Variable<rpc::WorkData> -- full per-coin WorkData kept coin-side |
| 11 | +// |
| 12 | +// web_server (shared core) historically held raw pointers to CONCRETE ltc types |
| 13 | +// (ltc::coin::NodeRPC, ltc::interfaces::Node) and called getwork()/submit on |
| 14 | +// them directly -- that names ltc:: symbols in web_server.cpp.o and breaks the |
| 15 | +// BTC link. This type collapses the embedded-vs-rpc decision plus the full |
| 16 | +// WorkData retention coin-side, and exposes only the coin-agnostic |
| 17 | +// core::coin::ICoinNode contract across the seam (WorkView, 2-arg submit). |
| 18 | +// |
| 19 | +// MWEB arity: ltc::coin::NodeRPC::submit_block_hex is the 3-arg |
| 20 | +// (block_hex, mweb, ignore_failure) LTC form. The ICoinNode override is the |
| 21 | +// coin-agnostic 2-arg form; it forwards to the 3-arg rpc with mweb="" coin-side. |
| 22 | +// The sole pre-seam caller (web_server.cpp:2730) already passed mweb="", so |
| 23 | +// dropping the mweb slot across the seam is behaviour-preserving for MWEB |
| 24 | +// submit. (See coin_node.cpp for the forward + the standing flag.) |
| 25 | +// --------------------------------------------------------------------------- |
| 26 | + |
| 27 | +#include <string> |
| 28 | + |
| 29 | +#include <core/coin/node_iface.hpp> |
| 30 | +#include <core/coin/work_view.hpp> |
| 31 | +#include <core/events.hpp> |
| 32 | + |
| 33 | +#include "rpc.hpp" |
| 34 | +#include "rpc_data.hpp" |
| 35 | +#include "template_builder.hpp" |
| 36 | + |
| 37 | +namespace ltc |
| 38 | +{ |
| 39 | + |
| 40 | +namespace coin |
| 41 | +{ |
| 42 | + |
| 43 | +class CoinNode : public core::coin::ICoinNode |
| 44 | +{ |
| 45 | + // Embedded in-process template source (EmbeddedCoinNode, via the |
| 46 | + // CoinNodeInterface base). May be null when the node runs RPC-only. |
| 47 | + // is_embedded() reports its presence. |
| 48 | + CoinNodeInterface* m_embedded = nullptr; |
| 49 | + |
| 50 | + // External coin-RPC client. May be null in embedded-only mode; it is the |
| 51 | + // sole sink for submit_block_hex(). has_rpc() reports its presence. |
| 52 | + NodeRPC* m_rpc = nullptr; |
| 53 | + |
| 54 | + // Full per-coin WorkData (incl. vector<Transaction> m_txs) retained |
| 55 | + // coin-side via work.set(wd); only the agnostic WorkView slice crosses the |
| 56 | + // seam into core/web_server. Replaces the old ltc::interfaces::Node::work |
| 57 | + // slot that web_server used to reach through m_coin_node. |
| 58 | + Variable<rpc::WorkData> work; |
| 59 | + |
| 60 | +public: |
| 61 | + CoinNode(CoinNodeInterface* embedded, NodeRPC* rpc) |
| 62 | + : m_embedded(embedded), m_rpc(rpc) {} |
| 63 | + |
| 64 | + core::coin::WorkView get_work_view() override; |
| 65 | + bool submit_block_hex(const std::string& block_hex, bool ignore_failure) override; |
| 66 | + |
| 67 | + bool is_embedded() const override { return m_embedded != nullptr; } |
| 68 | + bool has_rpc() const override { return m_rpc != nullptr; } |
| 69 | +}; |
| 70 | + |
| 71 | +} // namespace coin |
| 72 | + |
| 73 | +} // namespace ltc |
0 commit comments