The new RPC mempoolchanges
allows a client to retrieve mempool changes in a reliable way.
The client needs to start a dedicated stream:
0bitcoin-cli mempoolchanges start
11
This returns the stream ID and at this point it contains the mempool content and it will keep track of all mempool changes.
To retrieve the actual changes the client calls:
0bitcoin-cli mempoolchanges pull 1 10
1[
2]
This pulls up to 10 changes from the given stream.
Finally the client can stop the stream with
0bitcoin-cli mempoolchanges stop 1
Also, the stream is limited and if that limit is reached then the stream is automatically stopped.
TODO: option to block until changes are available.