You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The difference between hashblock (which we are using right now) and sequence for "Transactionhash added mempool" is more than 0.2s (for my host PC). This means there is a significant delay between these two events. Based on the code, we use a zmq notification to trigger the update() and check the node's mempool for new transactions. However, due to the significant delay, the hashblock subscription does not work properly.
This PR is open to choosing another subscription type and filtering the specific sequence event.
The zmq_event_receive is currently only consumed by the Waiter, signal, and is really only used in the wait method when the accept_block_notification is true. This only happens when wait is invoked in the main loop in electrs.rs which controls mempool updates like you noted in your description.
One issue I see with this approach is the overhead from the increased number of Mempool::update calls. The hashblock notification isn't being used as a way to detect if a transaction hash was added to the mempool, it's a way to communicate to the main loop that we need to remove confirmed txs from the mempool. Whenever it's called, we get all the txids from the node's mempool, remove the txids in our mempool that are no longer present, and make additional calls to retrieve the transactions we don't have. To avoid updates from being invoked for every tx, I'd suggest filtering for just block events.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #198
We should use a better zmq event for our use case.
Let's compare the delivery times of the
hashblockandsequenceevents.The difference between
hashblock(which we are using right now) andsequencefor "Transactionhash added mempool" is more than 0.2s (for my host PC). This means there is a significant delay between these two events. Based on the code, we use a zmq notification to trigger the update() and check the node's mempool for new transactions. However, due to the significant delay, thehashblocksubscription does not work properly.This PR is open to choosing another subscription type and filtering the specific
sequenceevent.