2021-03-25 13:23:53 +00:00
|
|
|
package governance
|
|
|
|
|
|
|
|
import (
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event/rolemanagement"
|
2021-05-18 07:40:21 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/native"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/native/noderoles"
|
2021-11-10 11:05:51 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
2021-03-25 13:23:53 +00:00
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
2021-05-18 07:40:21 +00:00
|
|
|
func (gp *Processor) HandleAlphabetSync(e event.Event) {
|
2021-11-10 11:05:51 +00:00
|
|
|
var (
|
|
|
|
typ string
|
|
|
|
hash util.Uint256
|
|
|
|
)
|
2021-05-18 07:40:21 +00:00
|
|
|
|
|
|
|
switch et := e.(type) {
|
|
|
|
case Sync:
|
|
|
|
typ = "sync"
|
2021-11-10 11:05:51 +00:00
|
|
|
hash = et.TxHash()
|
2021-05-18 07:40:21 +00:00
|
|
|
case rolemanagement.Designate:
|
|
|
|
if et.Role != noderoles.NeoFSAlphabet {
|
|
|
|
return
|
|
|
|
}
|
2021-11-10 11:05:51 +00:00
|
|
|
|
2021-05-18 07:40:21 +00:00
|
|
|
typ = native.DesignationEventName
|
2021-11-10 11:05:51 +00:00
|
|
|
hash = et.TxHash
|
2021-05-18 07:40:21 +00:00
|
|
|
default:
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
gp.log.Info("new event", zap.String("type", typ))
|
2021-03-25 13:23:53 +00:00
|
|
|
|
|
|
|
// send event to the worker pool
|
|
|
|
|
2021-11-10 11:05:51 +00:00
|
|
|
err := gp.pool.Submit(func() { gp.processAlphabetSync(hash) })
|
2021-03-25 13:23:53 +00:00
|
|
|
if err != nil {
|
|
|
|
// there system can be moved into controlled degradation stage
|
|
|
|
gp.log.Warn("governance worker pool drained",
|
|
|
|
zap.Int("capacity", gp.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|