以太坊日志如何索引事件主题?
当我在发出的事件中有两个索引输入时,以太坊日志索引了一对,或者单独单独索引?
我的意思是,如果我想使用两个主题过滤事件日志,那么这是直接从这对索引中获取信息,还是首先计算两个主题结果的相交?
示例:
event MyEvent(address indexed account, uint256 indexed selectedNumber);
当我想按帐户和SelectedNumber过滤时,将已经索引并直接返回索引,或者节点必须先获取帐户的索引事件,即SelectedNumber second的索引事件,然后将结果与结果相交?
我很想知道他们是在优化存储还是查询速度。
When I have two indexed inputs in an emitted event, the Ethereum logs index the pair or just each one separately?
I mean, if I want to filter event logs using two topics, then that get's the information directly from an index of the pair, or first an intersection of the two topics results is computed?
Example:
event MyEvent(address indexed account, uint256 indexed selectedNumber);
When I want to filter by account and selectedNumber, then the events for the pair are indexed already and directly returned, or the Node has to get the indexed events for account first, the ones for selectedNumber second, and intersect the result?
I'm curious to understand if they are optimizing storage or query speed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
索引主题的数量“仅”指定将存储在结果数组中的多少个项目。
myevent(地址,uint256)
。所得阵列存储,过滤和检索到确切的详细信息取决于每个节点客户端软件。
此答案描述了如何将它们存储在
go-ethereum
(当前最常用的客户端软件)中。据我了解,节点可用的所有事件日志都存储在某种形式的哈希图中,其中键是事件日志主题,并且值为log
type项目。我假设可以在某种程度上过滤键级,而不必一直循环所有值,但这是我知识的边缘,因此我不确定该如何确切起作用。The number of indexed topics "only" specifies how many items is going to be stored in the resulting array.
MyEvent(address,uint256)
.Specifics of how exactly are the resulting arrays stored, filtered, and retrieved, depend on each node client software.
This answer describes how they are stored in
go-ethereum
(currently the most used client software). As I understand it, all event logs available to the node are stored in some kind of a hashmap where the keys are the event log topics, and the values are theLog
type items. I'm assuming that it's somehow possible to filter on the keys level, not having to loop through all values all the time, but this is at the edge of my knowledge, so I'm not sure how exactly that works.