Skip to content

Commit a1db112

Browse files
committed
dash(S8): include leg-1 mempool_ingest + test registration (self-contained slice)
The reception-wire leg-1 header (wire_mempool_ingest) and the test_dash_node_reception_wire CMake registration were authored in the worktree but never committed to master -- this PR carries the FULL reception wire (legs 1+2), so a fresh checkout builds the KAT target and its mempool_ingest include. No file here is on master; purely additive, dash-only.
1 parent d37e776 commit a1db112

2 files changed

Lines changed: 83 additions & 0 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// SPDX-License-Identifier: AGPL-3.0-or-later
2+
#pragma once
3+
// ===========================================================================
4+
// dash reception wire (leg 1 of 4) -- interfaces::Node::new_tx -> maintainer.
5+
//
6+
// #672..#685 landed the node-held embedded coin-state bundle plus its async
7+
// CoinStateMaintainer, and proved that DRIVING the maintainer's on_*() methods
8+
// flips select_work() to the embedded arm. But nothing in a LIVE NodeImpl ever
9+
// subscribed the coin interface's reception events to that maintainer, so in a
10+
// running node the arm could never flip on its own -- the maintainer sat idle.
11+
// This is the first of the four reception legs
12+
// (on_mempool_tx / on_block_connected / on_new_tip / on_mn_list_update): the
13+
// mempool-relay leg, wired exactly as the dgb sibling (wire_mempool_ingest)
14+
// but routed through the maintainer's on_mempool_tx() so the readiness /
15+
// republish bookkeeping stays in one place.
16+
//
17+
// PAYLOAD-COMPLETE TODAY: interfaces::Node::new_tx carries a whole
18+
// coin::Transaction, and on_mempool_tx() never gates publication (an empty
19+
// mempool still yields a valid coinbase-only template), so this leg needs no
20+
// chain context. The other three legs are NOT wired here: on_block_connected
21+
// needs the connected block's HEIGHT (full_block carries none -- see bch's
22+
// block_connector deriving it from the chain tip), on_new_tip needs
23+
// bits/mtp/address-version params a bare best_block_hash does not carry, and
24+
// on_mn_list_update has no source event on interfaces::Node at all. Those are
25+
// their own slices; opening them touches the interface shape and is a design
26+
// decision surfaced to the integrator, not guessed here.
27+
//
28+
// LIFETIME: the handler captures `maint` by reference, so `maint` (and the
29+
// NodeCoinState it drives) MUST outlive `node`. The returned EventDisposable
30+
// lets a caller tear the subscription down explicitly; EventDisposable does
31+
// NOT auto-dispose on destruction, so if the handle is dropped the
32+
// subscription persists for the node's life.
33+
//
34+
// SCC (#143 / #22 / #39): pulls transaction.hpp (the tx serialization codec),
35+
// so include this header ONLY from a TU that already links the full dash codec
36+
// (main_dash + this leg's KAT), never a guard-weight TU -- identical to the
37+
// dgb mempool_ingest / embedded_tx_select btclibs-SCC trap.
38+
// ===========================================================================
39+
#include <memory>
40+
41+
#include <core/events.hpp>
42+
43+
#include "node_interface.hpp" // dash::interfaces::Node (new_tx feed)
44+
#include "coin_state_maintainer.hpp" // dash::coin::CoinStateMaintainer::on_mempool_tx
45+
#include "transaction.hpp" // dash::coin::Transaction -> MutableTransaction
46+
47+
namespace c2pool::dash
48+
{
49+
50+
// Subscribe `maint` to `node.new_tx`: every relayed tx is folded into the
51+
// maintainer's mempool via on_mempool_tx (fee_known=false until a UTXO view
52+
// feeds it, matching the embedded shaper's conservative default -- a P2P-fed
53+
// mempool cannot desync coinbasevalue versus a daemon's GBT). The mempool leg
54+
// never gates publication, so a rejected tx (bad utxo ref / already-in) is a
55+
// no-op here, not a demotion. Returns the subscription handle so the caller
56+
// controls teardown.
57+
inline std::shared_ptr<EventDisposable>
58+
wire_mempool_ingest(::dash::interfaces::Node& node,
59+
::dash::coin::CoinStateMaintainer& maint)
60+
{
61+
return node.new_tx.subscribe(
62+
[&maint](const ::dash::coin::Transaction& tx)
63+
{
64+
maint.on_mempool_tx(::dash::coin::MutableTransaction(tx));
65+
});
66+
}
67+
68+
} // namespace c2pool::dash

test/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,21 @@ if (BUILD_TESTING AND GTest_FOUND)
560560
target_link_libraries(test_dash_node_embedded_wire PRIVATE c2pool_payout c2pool_hashrate c2pool_merged_mining c2pool_storage pool) # OBJECT-lib SCC direct-naming (#22/#39)
561561
gtest_add_tests(test_dash_node_embedded_wire "" AUTO)
562562

563+
# Reception wire (legs 1-3): interfaces::Node reception Events ->
564+
# CoinStateMaintainer. Proves the wire_*_ingest() subscriptions fold off the
565+
# real Events (no direct poke), honour dispose(), and reach the embedded
566+
# template. Same header-only link set as the maintainer suite (no NodeImpl
567+
# -> no pool/storage dep).
568+
add_executable(test_dash_node_reception_wire test_dash_node_reception_wire.cpp)
569+
target_link_libraries(test_dash_node_reception_wire PRIVATE
570+
GTest::gtest_main GTest::gtest
571+
dash_x11 core
572+
nlohmann_json::nlohmann_json
573+
${Boost_LIBRARIES}
574+
)
575+
target_link_libraries(test_dash_node_reception_wire PRIVATE c2pool_payout c2pool_hashrate c2pool_merged_mining) # OBJECT-lib SCC direct-naming (#22/#39)
576+
gtest_add_tests(test_dash_node_reception_wire "" AUTO)
577+
563578
# DASH CSimplifiedMNListDiff (mnlistdiff wire, S8.1 leaf): vendored diff
564579
# round-trip + dashcore field-layout pin + apply_diff semantics. Header-only
565580
# over the SimplifiedMNList leaf + coin/transaction; no ltc/pool SCC dep.

0 commit comments

Comments
 (0)