+
Skip to content

Add an event handlers interface in the worker #129

Open
@smallyunet

Description

@smallyunet

Feature description

In our use case, we need to use different modules to handle tx.Events and distribute code logic based on different events, like this:

// in module A
func (m *Module) HandleTx(tx *juno.Transaction) error {
	for _, event := range tx.Events {
		if event.Type != "tx_log" {
			continue
		}

// in module B
func (m *Module) HandleTx(tx *juno.Transaction) error {
	for _, event := range tx.Events {
		if event.Type != "evm_tx_log" {
			continue
		}

So I think there needs to be an event handler in the Module interface?

Implementation proposal

After handle tx: https://github.com/forbole/juno/blob/cosmos/v0.50.x/parser/worker.go#L342

// call the event handlers
for i, event := range tx.Events {
	w.handEvnet(i, event)
}

Add a handleEvents method to allow the module to control the process based on events?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载