Skip to content

Commit

Permalink
FEAT: Events proc holder code placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusmihaic committed Dec 20, 2024
1 parent ea06b70 commit efb0632
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions process/block/sovereign/incomingHeader/incomingEventsProcHolder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package incomingHeader

import (
"errors"

"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-core-go/data"
)

type IncomingEventHandler interface {
ProcessEvent(event data.EventHandler) (*eventsResult, error)
IsInterfaceNil() bool
}

type incomingEventsProcHolder struct {
handlers map[string]IncomingEventHandler
}

func (iep *incomingEventsProcHolder) RegisterProcessor(event string, proc IncomingEventHandler) error {
if check.IfNil(proc) {
return errors.New("dsada")
}

iep.handlers[event] = proc
return nil
}

func (iep *incomingEventsProcHolder) ProcessIncomingEvent(event data.EventHandler) (*eventsResult, error) {
handler, found := iep.handlers[string(event.GetIdentifier())]
if !found {
return nil, errors.New("dsada")
}

return handler.ProcessEvent(event)
}

func (iep *incomingEventsProcHolder) IsInterfaceNil() bool {
return iep == nil
}

0 comments on commit efb0632

Please sign in to comment.