0

My understanding is that the lib's wsProvider.on('pending') method acts as a wrapper around the appropriate geth json-rpc method to listen for transactions in the mempool (pending transactions).

I tried to dig up documentation on this rpc method, but could not get what I was looking for.

I wish to clarify: -

  1. Does the listener only pick up NEW transactions that enter the pool after it is activated? How about transactions that were already in the pool when the listener was activated?

  2. In case the answer to Question 1 is that the listener gives all the transactions in the pool, not just new entrants, then what happens if a transaction leaves the pool after the the listener is activated? Does the listener simply never pick up that transaction?

  3. How accurate is the listener? Does it pick up ALL new transactions?

1 Answer 1

0
  1. The listener picks only the new transactions after it's activated. You are subscribing to the new pending transactions as they enter the mempool of the node you are connected to over WebSocket. Pre-existing transactions won't be streamed.

  2. It streams just the new entrants since activation.

  3. It depends on what you mean by ALL. Each node has its own mempool. Transactions from the mempool of one node propagate to the mempool of another node it's connected to, but there's no "global" mempool per se. It's always the mempools of many different nodes and it's always the mempool of the node you are connected to. I'm fairly certain that ethers is pretty robust in that it will pick all the transactions that enter the mempool of the node(s) it's connected to, but that's about it. There are specialized services too that strategically place their nodes in different geo locations and set up mempool transactions propagation between their nodes so that they can give the end user/builder the fastest and most complete mempool (basically an attempt to create the "global" mempool). Off the top of my head, these are BloXroute, Chainbound (Fibre), and others.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.