@@ -29,6 +29,7 @@ class Node : public btc::interfaces::Node
2929
3030 std::unique_ptr<NodeRPC> m_rpc;
3131 std::unique_ptr<NodeP2P<config_t >> m_p2p;
32+ bool m_request_mempool_on_connect{false }; // BIP 35 pull on (re)connect
3233
3334 void init_p2p ()
3435 {
@@ -79,10 +80,26 @@ class Node : public btc::interfaces::Node
7980 void start_p2p (const NetService& addr)
8081 {
8182 m_p2p = std::make_unique<NodeP2P<config_t >>(m_context, this , m_config);
83+ if (m_request_mempool_on_connect)
84+ m_p2p->enable_mempool_request ();
8285 m_p2p->connect (addr);
8386 LOG_INFO << " Coin P2P broadcaster connecting to " << addr.to_string ();
8487 }
8588
89+ // / Opt into the BIP 35 `mempool` request on (re)connect. Without this the
90+ // / embedded mempool only learns txs announced via `inv` AFTER we connect,
91+ // / so any tx already resident in the peer mempool at connect time is never
92+ // / pulled -> coinbase-only templates. Mirrors main_dgb. Idempotent; applies
93+ // / to the current peer immediately and to any peer start_p2p creates later.
94+ // / NOTE: the peer must advertise NODE_BLOOM (regtest: -peerbloomfilters=1)
95+ // / or NodeP2P skips the request to avoid a disconnect.
96+ void enable_mempool_request ()
97+ {
98+ m_request_mempool_on_connect = true ;
99+ if (m_p2p)
100+ m_p2p->enable_mempool_request ();
101+ }
102+
86103 // / Submit a block via P2P directly (faster propagation than RPC).
87104 void submit_block_p2p (BlockType& block)
88105 {
0 commit comments