[英]Different ways of getting Ethereum txpool pending transactions at Infura node via Web3.py
I would like to see the real-time pending transactions in the Ethereum txpool via Web3.py.我想通过 Web3.py 查看以太坊 txpool 中的实时待处理交易。 I do not run a local node but use Infura instead.
我不运行本地节点,而是使用 Infura。
According to the documentation of Web3.py, apparently one has three different options:根据 Web3.py 的文档,显然一个有三个不同的选项:
Option 1 is not viable as the API does not seem to support Infura node.选项 1 不可行,因为 API 似乎不支持 Infura 节点。 Thus I tried option 2 & 3 and they give me two different sets of pending transactions.
因此,我尝试了选项 2 和 3,它们给了我两组不同的待处理交易。 Does anyone know why it is the case?
有谁知道为什么会这样? Do the two methods retrieve different pending transactions?
这两种方法是否检索不同的待处理事务? Thanks!
谢谢!
Option 2 :选项2 :
pending_block= w3.eth.getBlock(block_identifier='pending', full_transactions=True)
pending_transactions= pending_block.['transactions']
Option 3 :选项3 :
pending_transactions_filter= w3.eth.filter('pending')
pending_transactions= pending_transactions_filter.get_new_entries()
These are different transaction sets fundamentally as it seems Option 2 just filters on a pending block, but Option 3 includes even more pending transactions that are not even in a pending block.这些是根本上不同的交易集,因为选项 2 似乎只是对挂起块进行过滤,但选项 3 包括甚至不在挂起块中的更多挂起交易。 This is evident to me because Option 2 allows you to get full tx content/info, but Option 3 only gives me the txhash IDs, many of which cannot be looked up.
这对我来说很明显,因为选项 2 允许您获得完整的 tx 内容/信息,但选项 3 只给我 txhash ID,其中许多无法查找。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.