[#1546] morph/event: Merge notification parser and handlers

They are decoupled, but it is an error to have a handler without a
corresponding parser. Register them together on the code level and get
rid of unreachable code.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-12-06 16:01:16 +03:00 committed by Evgenii Stratonikov
parent dfa51048a8
commit d0ce835fbf
13 changed files with 44 additions and 191 deletions

View file

@ -161,22 +161,6 @@ func New(p *Params) (*Processor, error) {
}, nil
}
// ListenerNotificationParsers for the 'event.Listener' event producer.
func (np *Processor) ListenerNotificationParsers() []event.NotificationParserInfo {
parsers := make([]event.NotificationParserInfo, 0, 3)
var p event.NotificationParserInfo
p.SetScriptHash(np.netmapClient.ContractAddress())
// new epoch event
p.SetType(newEpochNotification)
p.SetParser(netmapEvent.ParseNewEpoch)
parsers = append(parsers, p)
return parsers
}
// ListenerNotificationHandlers for the 'event.Listener' event producer.
func (np *Processor) ListenerNotificationHandlers() []event.NotificationHandlerInfo {
handlers := make([]event.NotificationHandlerInfo, 0, 3)
@ -187,7 +171,8 @@ func (np *Processor) ListenerNotificationHandlers() []event.NotificationHandlerI
// new epoch handler
i.SetType(newEpochNotification)
i.SetHandler(np.handleNewEpoch)
i.SetParser(netmapEvent.ParseNewEpoch)
i.AddHandler(np.handleNewEpoch)
handlers = append(handlers, i)
return handlers