frostfs-node/pkg/innerring/fetcher.go
Alexander Chuprov 9b113c3156
Some checks failed
DCO action / DCO (pull_request) Successful in 59s
Vulncheck / Vulncheck (pull_request) Successful in 1m4s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m55s
Build / Build Components (pull_request) Successful in 2m4s
Tests and linters / Staticcheck (pull_request) Successful in 2m38s
Tests and linters / Lint (pull_request) Successful in 3m16s
Tests and linters / Run gofumpt (pull_request) Successful in 3m54s
Tests and linters / Tests (pull_request) Successful in 4m12s
Tests and linters / gopls check (pull_request) Successful in 4m31s
Tests and linters / Tests with -race (pull_request) Successful in 4m38s
OCI image / Build container images (push) Failing after 18s
Vulncheck / Vulncheck (push) Successful in 1m2s
Pre-commit hooks / Pre-commit (push) Successful in 1m39s
Build / Build Components (push) Successful in 1m45s
Tests and linters / Staticcheck (push) Successful in 2m18s
Tests and linters / Run gofumpt (push) Successful in 2m46s
Tests and linters / Lint (push) Successful in 3m5s
Tests and linters / Tests with -race (push) Successful in 3m23s
Tests and linters / Tests (push) Successful in 3m52s
Tests and linters / gopls check (push) Successful in 4m18s
[#1613] morph: Add tracing for morph queries to neo-go
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
2025-02-05 16:38:20 +03:00

60 lines
1.9 KiB
Go

package innerring
import (
"context"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
nmClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
)
// NewIRFetcherWithNotary creates IrFetcherWithNotary.
//
// IrFetcherWithNotary can be used to obtain innerring key list if
// network that client is connected to supports notary contract.
//
// Passed client is required. Panics if nil.
func NewIRFetcherWithNotary(cli *client.Client) *IrFetcherWithNotary {
if cli == nil {
panic("could not init IRFetcher with notary: client must not be nil")
}
return &IrFetcherWithNotary{cli: cli}
}
// NewIRFetcherWithoutNotary creates IrFetcherWithoutNotary.
//
// IrFetcherWithoutNotary must be used to obtain innerring key list if
// network that netmap wrapper is connected to does not support notary
// contract.
//
// Passed netmap wrapper is required. Panics if nil.
func NewIRFetcherWithoutNotary(nm *nmClient.Client) *IrFetcherWithoutNotary {
if nm == nil {
panic("could not init IRFetcher without notary: netmap wrapper must not be nil")
}
return &IrFetcherWithoutNotary{nm: nm}
}
// IrFetcherWithNotary fetches keys using notary contract. Must be created
// with NewIRFetcherWithNotary.
type IrFetcherWithNotary struct {
cli *client.Client
}
// IrFetcherWithoutNotary fetches keys using netmap contract. Must be created
// with NewIRFetcherWithoutNotary.
type IrFetcherWithoutNotary struct {
nm *nmClient.Client
}
// InnerRingKeys fetches list of innerring keys from NeoFSAlphabet
// role in the sidechain.
func (fN IrFetcherWithNotary) InnerRingKeys(ctx context.Context) (keys.PublicKeys, error) {
return fN.cli.NeoFSAlphabetList(ctx)
}
// InnerRingKeys fetches list of innerring keys from netmap contract
// in the sidechain.
func (f IrFetcherWithoutNotary) InnerRingKeys(ctx context.Context) (keys.PublicKeys, error) {
return f.nm.GetInnerRingList(ctx)
}