-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEAT: Events proc holder code placeholder
- Loading branch information
1 parent
ea06b70
commit efb0632
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
process/block/sovereign/incomingHeader/incomingEventsProcHolder.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |