forked from TrueCloudLab/frostfs-node
[#21] ir: Add inner ring list relay processor
Signed-off-by: Alex Vanin <alexey@nspcc.ru>support/v0.27
parent
f11ae1035d
commit
4aee3de24e
|
@ -72,3 +72,19 @@ func (np *Processor) handleConfig(ev event.Event) {
|
|||
zap.Int("capacity", np.pool.Cap()))
|
||||
}
|
||||
}
|
||||
|
||||
func (np *Processor) handleUpdateInnerRing(ev event.Event) {
|
||||
updIR := ev.(neofsEvent.UpdateInnerRing) // todo: check panic in production
|
||||
np.log.Info("notification",
|
||||
zap.String("type", "update inner ring"),
|
||||
)
|
||||
|
||||
// send event to the worker pool
|
||||
|
||||
err := np.pool.Submit(func() { np.processUpdateInnerRing(&updIR) })
|
||||
if err != nil {
|
||||
// todo: move into controlled degradation stage
|
||||
np.log.Warn("neofs processor worker pool drained",
|
||||
zap.Int("capacity", np.pool.Cap()))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package neofs
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/invoke"
|
||||
neofsEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/neofs"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// Process update inner ring event by setting inner ring list value from
|
||||
// main chain in side chain.
|
||||
func (np *Processor) processUpdateInnerRing(list *neofsEvent.UpdateInnerRing) {
|
||||
if !np.activeState.IsActive() {
|
||||
np.log.Info("passive mode, ignore deposit")
|
||||
return
|
||||
}
|
||||
|
||||
err := invoke.UpdateInnerRing(np.morphClient, np.netmapContract,
|
||||
list.Keys(),
|
||||
)
|
||||
if err != nil {
|
||||
np.log.Error("can't relay update inner ring event", zap.Error(err))
|
||||
}
|
||||
}
|
|
@ -51,6 +51,7 @@ const (
|
|||
withdrawNotification = "Withdraw"
|
||||
chequeNotification = "Cheque"
|
||||
configNotification = "SetConfig"
|
||||
updateIRNotification = "InnerRingUpdate"
|
||||
)
|
||||
|
||||
// New creates neofs mainnet contract processor instance.
|
||||
|
@ -117,6 +118,13 @@ func (np *Processor) ListenerParsers() []event.ParserInfo {
|
|||
config.SetParser(neofsEvent.ParseConfig)
|
||||
parsers = append(parsers, config)
|
||||
|
||||
// update inner ring event
|
||||
updateIR := event.ParserInfo{}
|
||||
updateIR.SetType(updateIRNotification)
|
||||
updateIR.SetScriptHash(np.neofsContract)
|
||||
updateIR.SetParser(neofsEvent.ParseUpdateInnerRing)
|
||||
parsers = append(parsers, updateIR)
|
||||
|
||||
return parsers
|
||||
}
|
||||
|
||||
|
@ -152,6 +160,13 @@ func (np *Processor) ListenerHandlers() []event.HandlerInfo {
|
|||
config.SetHandler(np.handleConfig)
|
||||
handlers = append(handlers, config)
|
||||
|
||||
// updateIR handler
|
||||
updateIR := event.HandlerInfo{}
|
||||
updateIR.SetType(updateIRNotification)
|
||||
updateIR.SetScriptHash(np.neofsContract)
|
||||
updateIR.SetHandler(np.handleUpdateInnerRing)
|
||||
handlers = append(handlers, updateIR)
|
||||
|
||||
return handlers
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue