Sv2 Job Declarator Server (a.k.a. JDS) needs to keep an in-memory representation of the mempool so it can validate the custom jobs it receives via DeclareMiningJob message
currently, SRI JDS polls some RPCs against Bitcoin Core, but polling is rather suboptimal
on https://github.com/stratum-mining/sv2-apps/issues/26 we considered switching to an approach where we subscribe for the rawtx ZMQ feed… JDS would have some task that’s solely dedicated to consuming this feed
however, I hear ZMQ is not super reliable and this might be a good opportunity to leverage IPC, so I’m creating this issue to brainstorm with @ryanofsky @Sjors @ismaelsadeeq whether this would make sense
in order to provide something similar to a rawtx ZMQ feed, I can imagine the following:
- new
createRawTxFeedmethod underinterface Mining, returning aRawTxFeedas a result - new
interface RawTxFeedwith awaitNextmethod
(although I probably have blindspots and core devs might be able to imagine better approaches)
getTransactionsByWitnessId (to be potentially introduced via #34020) would be useful as a secondary mechanism to be leveraged if JDS receives a DeclareMiningJob contains some wtxid that hasn’t arrived on the feed yet, which could happen for two different potential reasons:
- this specific
wtxidis on the back of the queue while the chained calls toRawTxFeed.waitNextdidn’t fully catch up yet, in which casegetTransactionsByWitnessIdwill accelerate the process - Bitcoin Core simply hasn’t seen this tx yet, in which case
getTransactionsByWitnessIdwill return an error and JDS has no option but to sendProvideMissingTransactionsto JDC