forked from TrueCloudLab/frostfs-node
[#705] pkg/innerring: Fix disable notary mode
Get innerring list and committee in innerring indexer from interfaces, not from structs. Passing IR fetcher to indexer constructor depends on having Notary contract in sidechain(use NeoFS role or netmap contract). Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
8e66c67a74
commit
73ba35b379
2 changed files with 34 additions and 16 deletions
|
@ -7,14 +7,22 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
)
|
||||
|
||||
type (
|
||||
irFetcher interface {
|
||||
InnerRingKeys() (keys.PublicKeys, error)
|
||||
}
|
||||
|
||||
committeeFetcher interface {
|
||||
Committee() (keys.PublicKeys, error)
|
||||
}
|
||||
|
||||
innerRingIndexer struct {
|
||||
sync.RWMutex
|
||||
|
||||
cli *client.Client
|
||||
irFetcher irFetcher
|
||||
commFetcher committeeFetcher
|
||||
key *keys.PublicKey
|
||||
timeout time.Duration
|
||||
|
||||
|
@ -29,9 +37,10 @@ type (
|
|||
}
|
||||
)
|
||||
|
||||
func newInnerRingIndexer(cli *client.Client, key *keys.PublicKey, to time.Duration) *innerRingIndexer {
|
||||
func newInnerRingIndexer(comf committeeFetcher, irf irFetcher, key *keys.PublicKey, to time.Duration) *innerRingIndexer {
|
||||
return &innerRingIndexer{
|
||||
cli: cli,
|
||||
irFetcher: irf,
|
||||
commFetcher: comf,
|
||||
key: key,
|
||||
timeout: to,
|
||||
}
|
||||
|
@ -54,7 +63,7 @@ func (s *innerRingIndexer) update() (ind indexes, err error) {
|
|||
return s.ind, nil
|
||||
}
|
||||
|
||||
innerRing, err := s.cli.NeoFSAlphabetList()
|
||||
innerRing, err := s.irFetcher.InnerRingKeys()
|
||||
if err != nil {
|
||||
return indexes{}, err
|
||||
}
|
||||
|
@ -62,7 +71,7 @@ func (s *innerRingIndexer) update() (ind indexes, err error) {
|
|||
s.ind.innerRingIndex = keyPosition(s.key, innerRing)
|
||||
s.ind.innerRingSize = int32(len(innerRing))
|
||||
|
||||
alphabet, err := s.cli.Committee()
|
||||
alphabet, err := s.commFetcher.Committee()
|
||||
if err != nil {
|
||||
return indexes{}, err
|
||||
}
|
||||
|
|
|
@ -375,12 +375,6 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
|||
|
||||
server.pubKey = server.key.PublicKey().Bytes()
|
||||
|
||||
server.statusIndex = newInnerRingIndexer(
|
||||
server.morphClient,
|
||||
server.key.PublicKey(),
|
||||
cfg.GetDuration("indexer.cache_timeout"),
|
||||
)
|
||||
|
||||
auditPool, err := ants.NewPool(cfg.GetInt("audit.task.exec_pool_size"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -426,6 +420,21 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
|||
return nil, err
|
||||
}
|
||||
|
||||
var irf irFetcher
|
||||
|
||||
if server.morphClient.ProbeNotary() {
|
||||
irf = NewIRFetcherWithNotary(server.morphClient)
|
||||
} else {
|
||||
irf = NewIRFetcherWithoutNotary(server.netmapClient)
|
||||
}
|
||||
|
||||
server.statusIndex = newInnerRingIndexer(
|
||||
server.morphClient,
|
||||
irf,
|
||||
server.key.PublicKey(),
|
||||
cfg.GetDuration("indexer.cache_timeout"),
|
||||
)
|
||||
|
||||
// create global runtime config reader
|
||||
globalConfig := config.NewGlobalConfigReader(cfg, server.netmapClient)
|
||||
|
||||
|
|
Loading…
Reference in a new issue