2021-03-25 13:23:53 +00:00
|
|
|
package governance
|
|
|
|
|
|
|
|
import (
|
2024-10-21 07:22:54 +00:00
|
|
|
"context"
|
|
|
|
|
2023-04-12 14:35:10 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
2023-05-26 10:24:41 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors"
|
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"
|
|
|
|
)
|
|
|
|
|
2024-10-21 09:21:01 +00:00
|
|
|
func (gp *Processor) HandleAlphabetSync(ctx context.Context, 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
|
|
|
|
}
|
|
|
|
|
2024-10-21 09:21:01 +00:00
|
|
|
gp.log.Info(ctx, logs.GovernanceNewEvent, zap.String("type", typ))
|
2021-03-25 13:23:53 +00:00
|
|
|
|
|
|
|
// send event to the worker pool
|
|
|
|
|
2023-05-26 10:24:41 +00:00
|
|
|
err := processors.SubmitEvent(gp.pool, gp.metrics, "alphabet_sync", func() bool {
|
2024-10-21 09:21:01 +00:00
|
|
|
return gp.processAlphabetSync(ctx, hash)
|
2023-05-26 10:24:41 +00:00
|
|
|
})
|
2021-03-25 13:23:53 +00:00
|
|
|
if err != nil {
|
|
|
|
// there system can be moved into controlled degradation stage
|
2024-10-21 09:21:01 +00:00
|
|
|
gp.log.Warn(ctx, logs.GovernanceGovernanceWorkerPoolDrained,
|
2021-03-25 13:23:53 +00:00
|
|
|
zap.Int("capacity", gp.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|