2020-07-24 13:54:03 +00:00
|
|
|
package innerring
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
// ContractProcessor interface defines functions for binding event producers
|
|
|
|
// such as event.Listener and Timers with contract processor.
|
|
|
|
ContractProcessor interface {
|
|
|
|
ListenerParsers() []event.ParserInfo
|
|
|
|
ListenerHandlers() []event.HandlerInfo
|
|
|
|
TimersHandlers() []event.HandlerInfo
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func connectListenerWithProcessor(l event.Listener, p ContractProcessor) {
|
|
|
|
// register parsers
|
|
|
|
for _, parser := range p.ListenerParsers() {
|
|
|
|
l.SetParser(parser)
|
|
|
|
}
|
|
|
|
|
|
|
|
// register handlers
|
|
|
|
for _, handler := range p.ListenerHandlers() {
|
|
|
|
l.RegisterHandler(handler)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// bindMorphProcessor connects both morph chain listener handlers and
|
|
|
|
// local timers handlers.
|
|
|
|
func bindMorphProcessor(proc ContractProcessor, s *Server) error {
|
|
|
|
connectListenerWithProcessor(s.morphListener, proc)
|
2021-01-22 15:49:52 +00:00
|
|
|
return nil
|
2020-07-24 13:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// bindMainnetProcessor connects both mainnet chain listener handlers and
|
|
|
|
// local timers handlers.
|
|
|
|
func bindMainnetProcessor(proc ContractProcessor, s *Server) error {
|
|
|
|
connectListenerWithProcessor(s.mainnetListener, proc)
|
2021-01-22 15:49:52 +00:00
|
|
|
return nil
|
2020-07-24 13:54:03 +00:00
|
|
|
}
|