forked from TrueCloudLab/frostfs-node
[#720] pkg/innerring: Check Notary availability automatically
Do not read `without_notary` config value from env. Make morph client constructor return client without notary support. Enabling notary support should be done with public `EnableNotarySupport` method separately. Notary availability is deducted with client. Further, if notary is presented on chain its support is enabled at the corresponding client. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
28aa0f521e
commit
896c749b92
4 changed files with 56 additions and 59 deletions
|
@ -2,7 +2,6 @@ package client
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
||||
|
@ -28,8 +27,6 @@ type cfg struct {
|
|||
gas util.Uint160 // native gas script-hash
|
||||
|
||||
waitInterval time.Duration
|
||||
|
||||
notaryOpts []NotaryOption
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -47,6 +44,8 @@ func defaultConfig() *cfg {
|
|||
}
|
||||
|
||||
// New creates, initializes and returns the Client instance.
|
||||
// Notary support should be enabled with EnableNotarySupport client
|
||||
// method separately.
|
||||
//
|
||||
// If private key is nil, it panics.
|
||||
//
|
||||
|
@ -105,12 +104,6 @@ func New(key *keys.PrivateKey, endpoint string, opts ...Option) (*Client, error)
|
|||
waitInterval: cfg.waitInterval,
|
||||
}
|
||||
|
||||
if len(cfg.notaryOpts) != 0 {
|
||||
if err := c.enableNotarySupport(cfg.notaryOpts...); err != nil {
|
||||
return nil, fmt.Errorf("can't enable notary support: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
||||
|
@ -155,10 +148,3 @@ func WithLogger(logger *logger.Logger) Option {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithNotaryOptions enables notary support and sets notary options for the client.
|
||||
func WithNotaryOptions(opts ...NotaryOption) Option {
|
||||
return func(c *cfg) {
|
||||
c.notaryOpts = opts
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue