Blockchain 如何通过web3从块中获取事务历史记录?

Blockchain 如何通过web3从块中获取事务历史记录?,blockchain,ethereum,Blockchain,Ethereum,我现在有一个私有链,我想查询交易历史。我知道web3已经提供了这些方法web3.eth.blockNumber/web3.eth.getBlockTransactionCount/web3.eth.getTransactionFromBlock。因此,我可以通过get latest blocknumber(假设它是n)获得事务历史记录。范围从n到0,调用web3.eth.getBlockTransactionCount(i),然后通过web3.eth.getTransactionFromBloc

我现在有一个私有链,我想查询交易历史。我知道web3已经提供了这些方法web3.eth.blockNumber/web3.eth.getBlockTransactionCount/web3.eth.getTransactionFromBlock。因此,我可以通过get latest blocknumber(假设它是n)获得事务历史记录。范围从n到0,调用web3.eth.getBlockTransactionCount(i),然后通过web3.eth.getTransactionFromBlock获取事务。但这只是浪费时间,效率低下。
因此,我想知道如何通过web3或rpc或其他方式有效地从块中获取事务历史记录?

对于每个块,您可以将
true
作为第二个参数传递给


thxs,它在某种程度上有所帮助,但我认为它仍然有点低效率。我的意思是,如果我有一个合同和一个映射(mapping(address=>User)public users;),我可以在存储用户信息的哪个块上立即获取用户信息。无论如何,谢谢你的回答^^
web3.eth.getBlock(blockHashOrBlockNumber [, returnTransactionObjects] [, callback])