forked from TrueCloudLab/frostfs-node
[#681] ir: Do not require MainNet attributes
If `WITHOUT_MAINNET` environmental variable is `true`: - Do not read `NeoFS` and `processing` script-hashes from envs; - Do not init Governance processor; - Do not init NeoFS processor. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
af412f7874
commit
9da777ac8c
2 changed files with 60 additions and 55 deletions
|
@ -3,6 +3,9 @@ Changelog for NeoFS Node
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Do not require MainNet attributes in "Without MainNet" mode ([#663](https://github.com/nspcc-dev/neofs-node/issues/663)).
|
||||||
|
|
||||||
## [0.22.2] - 2021-07-07
|
## [0.22.2] - 2021-07-07
|
||||||
|
|
||||||
Updated broken version of NeoFS API Go.
|
Updated broken version of NeoFS API Go.
|
||||||
|
|
|
@ -305,8 +305,10 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
||||||
|
|
||||||
fmt.Println(hex.EncodeToString(server.key.PublicKey().Bytes()))
|
fmt.Println(hex.EncodeToString(server.key.PublicKey().Bytes()))
|
||||||
|
|
||||||
|
withoutMainNet := cfg.GetBool("without_mainnet")
|
||||||
|
|
||||||
// get all script hashes of contracts
|
// get all script hashes of contracts
|
||||||
server.contracts, err = parseContracts(cfg)
|
server.contracts, err = parseContracts(cfg, withoutMainNet)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -342,8 +344,6 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
withoutMainNet := cfg.GetBool("without_mainnet")
|
|
||||||
|
|
||||||
if withoutMainNet {
|
if withoutMainNet {
|
||||||
// This works as long as event Listener starts listening loop once,
|
// This works as long as event Listener starts listening loop once,
|
||||||
// otherwise Server.Start will run two similar routines.
|
// otherwise Server.Start will run two similar routines.
|
||||||
|
@ -525,6 +525,13 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var alphaSync event.Handler
|
||||||
|
|
||||||
|
if withoutMainNet {
|
||||||
|
alphaSync = func(event.Event) {
|
||||||
|
log.Debug("alphabet keys sync is disabled")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// create governance processor
|
// create governance processor
|
||||||
governanceProcessor, err := governance.New(&governance.Params{
|
governanceProcessor, err := governance.New(&governance.Params{
|
||||||
Log: log,
|
Log: log,
|
||||||
|
@ -541,13 +548,6 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var alphaSync event.Handler
|
|
||||||
|
|
||||||
if withoutMainNet {
|
|
||||||
alphaSync = func(event.Event) {
|
|
||||||
log.Debug("alphabet keys sync is disabled")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
alphaSync = governanceProcessor.HandleAlphabetSync
|
alphaSync = governanceProcessor.HandleAlphabetSync
|
||||||
err = bindMainnetProcessor(governanceProcessor, server)
|
err = bindMainnetProcessor(governanceProcessor, server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -625,6 +625,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !withoutMainNet {
|
||||||
// create mainnnet neofs processor
|
// create mainnnet neofs processor
|
||||||
neofsProcessor, err := neofs.New(&neofs.Params{
|
neofsProcessor, err := neofs.New(&neofs.Params{
|
||||||
Log: log,
|
Log: log,
|
||||||
|
@ -650,6 +651,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// create alphabet processor
|
// create alphabet processor
|
||||||
alphabetProcessor, err := alphabet.New(&alphabet.Params{
|
alphabetProcessor, err := alphabet.New(&alphabet.Params{
|
||||||
|
@ -828,19 +830,29 @@ func createClient(ctx context.Context, p *chainParams, notaryOpts ...client.Nota
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseContracts(cfg *viper.Viper) (*contracts, error) {
|
func parseContracts(cfg *viper.Viper, withoutMainNet bool) (*contracts, error) {
|
||||||
var (
|
var (
|
||||||
result = new(contracts)
|
result = new(contracts)
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if !withoutMainNet {
|
||||||
|
result.neofs, err = util.Uint160DecodeStringLE(cfg.GetString("contracts.neofs"))
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("ir: can't read neofs script-hash: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
result.processing, err = util.Uint160DecodeStringLE(cfg.GetString("contracts.processing"))
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("ir: can't read processing script-hash: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
netmapContractStr := cfg.GetString("contracts.netmap")
|
netmapContractStr := cfg.GetString("contracts.netmap")
|
||||||
neofsContractStr := cfg.GetString("contracts.neofs")
|
|
||||||
balanceContractStr := cfg.GetString("contracts.balance")
|
balanceContractStr := cfg.GetString("contracts.balance")
|
||||||
containerContractStr := cfg.GetString("contracts.container")
|
containerContractStr := cfg.GetString("contracts.container")
|
||||||
auditContractStr := cfg.GetString("contracts.audit")
|
auditContractStr := cfg.GetString("contracts.audit")
|
||||||
proxyContractStr := cfg.GetString("contracts.proxy")
|
proxyContractStr := cfg.GetString("contracts.proxy")
|
||||||
processingContractStr := cfg.GetString("contracts.processing")
|
|
||||||
reputationContractStr := cfg.GetString("contracts.reputation")
|
reputationContractStr := cfg.GetString("contracts.reputation")
|
||||||
neofsIDContractStr := cfg.GetString("contracts.neofsid")
|
neofsIDContractStr := cfg.GetString("contracts.neofsid")
|
||||||
|
|
||||||
|
@ -849,11 +861,6 @@ func parseContracts(cfg *viper.Viper) (*contracts, error) {
|
||||||
return nil, fmt.Errorf("ir: can't read netmap script-hash: %w", err)
|
return nil, fmt.Errorf("ir: can't read netmap script-hash: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
result.neofs, err = util.Uint160DecodeStringLE(neofsContractStr)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("ir: can't read neofs script-hash: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
result.balance, err = util.Uint160DecodeStringLE(balanceContractStr)
|
result.balance, err = util.Uint160DecodeStringLE(balanceContractStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("ir: can't read balance script-hash: %w", err)
|
return nil, fmt.Errorf("ir: can't read balance script-hash: %w", err)
|
||||||
|
@ -874,11 +881,6 @@ func parseContracts(cfg *viper.Viper) (*contracts, error) {
|
||||||
return nil, fmt.Errorf("ir: can't read proxy script-hash: %w", err)
|
return nil, fmt.Errorf("ir: can't read proxy script-hash: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
result.processing, err = util.Uint160DecodeStringLE(processingContractStr)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("ir: can't read processing script-hash: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
result.reputation, err = util.Uint160DecodeStringLE(reputationContractStr)
|
result.reputation, err = util.Uint160DecodeStringLE(reputationContractStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("ir: can't read reputation script-hash: %w", err)
|
return nil, fmt.Errorf("ir: can't read reputation script-hash: %w", err)
|
||||||
|
|
Loading…
Reference in a new issue