Skip to content

Commit 57908a7

Browse files
committed
interfaces: Add Chain::requestMempoolTransactions
1 parent 0440481 commit 57908a7

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/interfaces/chain.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,13 @@ class ChainImpl : public Chain
367367
{
368368
return MakeUnique<RpcHandlerImpl>(command);
369369
}
370+
void requestMempoolTransactions(Notifications& notifications) override
371+
{
372+
LOCK2(::cs_main, ::mempool.cs);
373+
for (const CTxMemPoolEntry& entry : ::mempool.mapTx) {
374+
notifications.TransactionAddedToMempool(entry.GetSharedTx());
375+
}
376+
}
370377
};
371378
} // namespace
372379

src/interfaces/chain.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,16 @@ class Chain
269269
//! Register handler for RPC. Command is not copied, so reference
270270
//! needs to remain valid until Handler is disconnected.
271271
virtual std::unique_ptr<Handler> handleRpc(const CRPCCommand& command) = 0;
272+
273+
//! Synchronously send TransactionAddedToMempool notifications about all
274+
//! current mempool transactions to the specified handler and return after
275+
//! the last one is sent. These notifications aren't coordinated with async
276+
//! notifications sent by handleNotifications, so out of date async
277+
//! notifications from handleNotifications can arrive during and after
278+
//! synchronous notifications from requestMempoolTransactions. Clients need
279+
//! to be prepared to handle this by ignoring notifications about unknown
280+
//! removed transactions and already added new transactions.
281+
virtual void requestMempoolTransactions(Notifications& notifications) = 0;
272282
};
273283

274284
//! Interface to let node manage chain clients (wallets, or maybe tools for

0 commit comments

Comments
 (0)