forked from TrueCloudLab/frostfs-node
[#447] innerring: Use governance processor in inner ring
Network map processors creates sync event once per epoch. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
d0d1731af7
commit
3fe5962e92
4 changed files with 35 additions and 2 deletions
|
@ -16,6 +16,7 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/audit"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/balance"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/container"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/governance"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/neofs"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/netmap"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/settlement"
|
||||
|
@ -423,6 +424,20 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// create governance processor
|
||||
governanceProcessor, err := governance.New(&governance.Params{
|
||||
Log: log,
|
||||
NeoFSContract: server.contracts.neofs,
|
||||
AlphabetState: server,
|
||||
EpochState: server,
|
||||
Voter: server,
|
||||
MorphClient: server.morphClient,
|
||||
MainnetClient: server.mainnetClient,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// create netmap processor
|
||||
netmapProcessor, err := netmap.New(&netmap.Params{
|
||||
Log: log,
|
||||
|
@ -441,6 +456,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
|||
AuditSettlementsHandler: server.onlyAlphabetEventHandler(
|
||||
settlementProcessor.HandleAuditEvent,
|
||||
),
|
||||
AlphabetSyncHandler: governanceProcessor.HandleAlphabetSync,
|
||||
NodeValidator: locodeValidator,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
@ -3,6 +3,7 @@ package netmap
|
|||
import (
|
||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/invoke"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/audit"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/governance"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/settlement"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
@ -38,6 +39,7 @@ func (np *Processor) processNewEpoch(epoch uint64) {
|
|||
np.handleCleanupTick(netmapCleanupTick{epoch: epoch})
|
||||
np.handleNewAudit(audit.NewAuditStartEvent(epoch))
|
||||
np.handleAuditSettlements(settlement.NewAuditEvent(epoch))
|
||||
np.handleAlphabetSync(governance.NewSyncEvent())
|
||||
}
|
||||
|
||||
// Process new epoch tick by invoking new epoch method in network map contract.
|
||||
|
|
|
@ -61,6 +61,7 @@ type (
|
|||
|
||||
handleNewAudit event.Handler
|
||||
handleAuditSettlements event.Handler
|
||||
handleAlphabetSync event.Handler
|
||||
|
||||
nodeValidator NodeValidator
|
||||
}
|
||||
|
@ -80,6 +81,7 @@ type (
|
|||
|
||||
HandleAudit event.Handler
|
||||
AuditSettlementsHandler event.Handler
|
||||
AlphabetSyncHandler event.Handler
|
||||
|
||||
NodeValidator NodeValidator
|
||||
}
|
||||
|
@ -108,6 +110,8 @@ func New(p *Params) (*Processor, error) {
|
|||
return nil, errors.New("ir/netmap: audit handler is not set")
|
||||
case p.AuditSettlementsHandler == nil:
|
||||
return nil, errors.New("ir/netmap: audit settlement handler is not set")
|
||||
case p.AlphabetSyncHandler == nil:
|
||||
return nil, errors.New("ir/netmap: alphabet sync handler is not set")
|
||||
case p.ContainerWrapper == nil:
|
||||
return nil, errors.New("ir/netmap: container contract wrapper is not set")
|
||||
case p.NodeValidator == nil:
|
||||
|
@ -135,6 +139,8 @@ func New(p *Params) (*Processor, error) {
|
|||
|
||||
handleAuditSettlements: p.AuditSettlementsHandler,
|
||||
|
||||
handleAlphabetSync: p.AlphabetSyncHandler,
|
||||
|
||||
nodeValidator: p.NodeValidator,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package innerring
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/invoke"
|
||||
|
@ -95,13 +97,20 @@ func (s *Server) voteForSidechainValidator(validators keys.PublicKeys) error {
|
|||
|
||||
// InitAndVoteForSidechainValidator is a public function to use outside of
|
||||
// inner ring daemon execution. It initialize inner ring structure with data
|
||||
// from blockchain and then calls vote method on corresponding alphabet contract.
|
||||
// from blockchain and then calls vote method on alphabet contracts.
|
||||
func (s *Server) InitAndVoteForSidechainValidator(validators keys.PublicKeys) error {
|
||||
err := s.initConfigFromBlockchain()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.VoteForSidechainValidator(validators)
|
||||
}
|
||||
|
||||
// VoteForSidechainValidator calls vote method on alphabet contracts with
|
||||
// provided list of keys.
|
||||
func (s *Server) VoteForSidechainValidator(validators keys.PublicKeys) error {
|
||||
sort.Sort(validators)
|
||||
return s.voteForSidechainValidator(validators)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue