forked from TrueCloudLab/frostfs-node
[#21] ir: Add inner ring list relay processor
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
f11ae1035d
commit
4aee3de24e
3 changed files with 54 additions and 0 deletions
|
@ -72,3 +72,19 @@ func (np *Processor) handleConfig(ev event.Event) {
|
||||||
zap.Int("capacity", np.pool.Cap()))
|
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()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
23
pkg/innerring/processors/neofs/process_update.go
Normal file
23
pkg/innerring/processors/neofs/process_update.go
Normal file
|
@ -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"
|
withdrawNotification = "Withdraw"
|
||||||
chequeNotification = "Cheque"
|
chequeNotification = "Cheque"
|
||||||
configNotification = "SetConfig"
|
configNotification = "SetConfig"
|
||||||
|
updateIRNotification = "InnerRingUpdate"
|
||||||
)
|
)
|
||||||
|
|
||||||
// New creates neofs mainnet contract processor instance.
|
// New creates neofs mainnet contract processor instance.
|
||||||
|
@ -117,6 +118,13 @@ func (np *Processor) ListenerParsers() []event.ParserInfo {
|
||||||
config.SetParser(neofsEvent.ParseConfig)
|
config.SetParser(neofsEvent.ParseConfig)
|
||||||
parsers = append(parsers, config)
|
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
|
return parsers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,6 +160,13 @@ func (np *Processor) ListenerHandlers() []event.HandlerInfo {
|
||||||
config.SetHandler(np.handleConfig)
|
config.SetHandler(np.handleConfig)
|
||||||
handlers = append(handlers, config)
|
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
|
return handlers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue