forked from TrueCloudLab/frostfs-node
[#770] pkg/innerring: Add NotaryContractProcessor
interface
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
d40f898ee5
commit
4e5618aecb
2 changed files with 25 additions and 0 deletions
|
@ -12,6 +12,17 @@ type (
|
|||
ListenerNotificationHandlers() []event.NotificationHandlerInfo
|
||||
TimersHandlers() []event.NotificationHandlerInfo
|
||||
}
|
||||
|
||||
// NotaryContractProcessor interface defines function for binding notary event
|
||||
// producers such as event.Listener with contract processor.
|
||||
//
|
||||
// This interface is optional for contract processor. If contract processor
|
||||
// supports notary event handling, it should implement both ContractProcessor
|
||||
// and NotaryContractProcessor interfaces.
|
||||
NotaryContractProcessor interface {
|
||||
ListenerNotaryParsers() []event.NotaryParserInfo
|
||||
ListenerNotaryHandlers() []event.NotaryHandlerInfo
|
||||
}
|
||||
)
|
||||
|
||||
func connectListenerWithProcessor(l event.Listener, p ContractProcessor) {
|
||||
|
@ -24,6 +35,17 @@ func connectListenerWithProcessor(l event.Listener, p ContractProcessor) {
|
|||
for _, handler := range p.ListenerNotificationHandlers() {
|
||||
l.RegisterNotificationHandler(handler)
|
||||
}
|
||||
|
||||
// add notary handlers if processor supports it
|
||||
if notaryProcessor, ok := p.(NotaryContractProcessor); ok {
|
||||
for _, notaryParser := range notaryProcessor.ListenerNotaryParsers() {
|
||||
l.SetNotaryParser(notaryParser)
|
||||
}
|
||||
|
||||
for _, notaryHandler := range notaryProcessor.ListenerNotaryHandlers() {
|
||||
l.RegisterNotaryHandler(notaryHandler)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// bindMorphProcessor connects morph chain listener handlers.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue