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,16 +7,24 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
irFetcher interface {
|
||||||
|
InnerRingKeys() (keys.PublicKeys, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
committeeFetcher interface {
|
||||||
|
Committee() (keys.PublicKeys, error)
|
||||||
|
}
|
||||||
|
|
||||||
innerRingIndexer struct {
|
innerRingIndexer struct {
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
|
|
||||||
cli *client.Client
|
irFetcher irFetcher
|
||||||
key *keys.PublicKey
|
commFetcher committeeFetcher
|
||||||
timeout time.Duration
|
key *keys.PublicKey
|
||||||
|
timeout time.Duration
|
||||||
|
|
||||||
ind indexes
|
ind indexes
|
||||||
|
|
||||||
|
@ -29,11 +37,12 @@ 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{
|
return &innerRingIndexer{
|
||||||
cli: cli,
|
irFetcher: irf,
|
||||||
key: key,
|
commFetcher: comf,
|
||||||
timeout: to,
|
key: key,
|
||||||
|
timeout: to,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +63,7 @@ func (s *innerRingIndexer) update() (ind indexes, err error) {
|
||||||
return s.ind, nil
|
return s.ind, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
innerRing, err := s.cli.NeoFSAlphabetList()
|
innerRing, err := s.irFetcher.InnerRingKeys()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return indexes{}, err
|
return indexes{}, err
|
||||||
}
|
}
|
||||||
|
@ -62,7 +71,7 @@ func (s *innerRingIndexer) update() (ind indexes, err error) {
|
||||||
s.ind.innerRingIndex = keyPosition(s.key, innerRing)
|
s.ind.innerRingIndex = keyPosition(s.key, innerRing)
|
||||||
s.ind.innerRingSize = int32(len(innerRing))
|
s.ind.innerRingSize = int32(len(innerRing))
|
||||||
|
|
||||||
alphabet, err := s.cli.Committee()
|
alphabet, err := s.commFetcher.Committee()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return indexes{}, err
|
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.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"))
|
auditPool, err := ants.NewPool(cfg.GetInt("audit.task.exec_pool_size"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -426,6 +420,21 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
||||||
return nil, err
|
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
|
// create global runtime config reader
|
||||||
globalConfig := config.NewGlobalConfigReader(cfg, server.netmapClient)
|
globalConfig := config.NewGlobalConfigReader(cfg, server.netmapClient)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue