mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
Add function to find event by log topic (aka. id)
This commit is contained in:
parent
cdf5982cfc
commit
fc21f62a31
1 changed files with 11 additions and 0 deletions
|
|
@ -147,3 +147,14 @@ func (abi *ABI) MethodById(sigdata []byte) (*Method, error) {
|
|||
}
|
||||
return nil, fmt.Errorf("no method with id: %#x", sigdata[:4])
|
||||
}
|
||||
|
||||
// EventById looks up an event by the first topic hash
|
||||
// returns nil if none was found
|
||||
func (abi *ABI) EventById(topic []byte) (*Event, error) {
|
||||
for _, event := range abi.Events {
|
||||
if bytes.Equal(event.Id().Bytes(), topic) {
|
||||
return &event, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("no event with id: %#x", topic)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue