2020-07-10 17:17:51 +03:00
|
|
|
package event
|
|
|
|
|
2021-01-20 20:08:06 +03:00
|
|
|
import (
|
2024-10-21 12:21:01 +03:00
|
|
|
"context"
|
|
|
|
|
2021-01-20 20:08:06 +03:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/block"
|
|
|
|
)
|
|
|
|
|
2020-07-10 17:17:51 +03:00
|
|
|
// Handler is an Event processing function.
|
2024-10-21 12:21:01 +03:00
|
|
|
type Handler func(context.Context, Event)
|
2020-07-10 17:17:51 +03:00
|
|
|
|
2021-01-20 20:08:06 +03:00
|
|
|
// BlockHandler is a chain block processing function.
|
2024-10-21 16:27:28 +03:00
|
|
|
type BlockHandler func(context.Context, *block.Block)
|
2021-01-20 20:08:06 +03:00
|
|
|
|
2021-08-12 18:24:17 +03:00
|
|
|
// NotificationHandlerInfo is a structure that groups
|
2020-07-10 17:17:51 +03:00
|
|
|
// the parameters of the handler of particular
|
|
|
|
// contract event.
|
2021-08-12 18:24:17 +03:00
|
|
|
type NotificationHandlerInfo struct {
|
2020-07-10 17:17:51 +03:00
|
|
|
scriptHashWithType
|
|
|
|
|
2024-12-06 16:01:16 +03:00
|
|
|
parser NotificationParser
|
|
|
|
handlers []Handler
|
2020-07-10 17:17:51 +03:00
|
|
|
}
|
|
|
|
|
2024-12-06 16:01:16 +03:00
|
|
|
// SetParser is an event handler setter.
|
|
|
|
func (s *NotificationHandlerInfo) SetParser(p NotificationParser) {
|
|
|
|
s.parser = p
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddHandler adds an event handler.
|
|
|
|
func (s *NotificationHandlerInfo) AddHandler(v Handler) {
|
|
|
|
s.handlers = append(s.handlers, v)
|
2020-07-10 17:17:51 +03:00
|
|
|
}
|
|
|
|
|
2020-07-24 16:54:03 +03:00
|
|
|
// Handler returns an event handler.
|
2024-12-06 16:01:16 +03:00
|
|
|
func (s NotificationHandlerInfo) Handlers() []Handler {
|
|
|
|
return s.handlers
|
2020-07-10 17:17:51 +03:00
|
|
|
}
|
2021-08-15 20:03:15 +03:00
|
|
|
|
|
|
|
// NotaryHandlerInfo is a structure that groups
|
|
|
|
// the parameters of the handler of particular
|
|
|
|
// notary event.
|
|
|
|
type NotaryHandlerInfo struct {
|
|
|
|
notaryRequestTypes
|
|
|
|
|
|
|
|
h Handler
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetHandler is an event handler setter.
|
|
|
|
func (nhi *NotaryHandlerInfo) SetHandler(v Handler) {
|
|
|
|
nhi.h = v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handler returns an event handler.
|
|
|
|
func (nhi NotaryHandlerInfo) Handler() Handler {
|
|
|
|
return nhi.h
|
|
|
|
}
|