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]
|
||||
|
||||
### 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
|
||||
|
||||
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()))
|
||||
|
||||
withoutMainNet := cfg.GetBool("without_mainnet")
|
||||
|
||||
// get all script hashes of contracts
|
||||
server.contracts, err = parseContracts(cfg)
|
||||
server.contracts, err = parseContracts(cfg, withoutMainNet)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -342,8 +344,6 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
|||
return nil, err
|
||||
}
|
||||
|
||||
withoutMainNet := cfg.GetBool("without_mainnet")
|
||||
|
||||
if withoutMainNet {
|
||||
// This works as long as event Listener starts listening loop once,
|
||||
// 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
|
||||
}
|
||||
|
||||
var alphaSync event.Handler
|
||||
|
||||
if withoutMainNet {
|
||||
alphaSync = func(event.Event) {
|
||||
log.Debug("alphabet keys sync is disabled")
|
||||
}
|
||||
} else {
|
||||
// create governance processor
|
||||
governanceProcessor, err := governance.New(&governance.Params{
|
||||
Log: log,
|
||||
|
@ -541,13 +548,6 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
|||
return nil, err
|
||||
}
|
||||
|
||||
var alphaSync event.Handler
|
||||
|
||||
if withoutMainNet {
|
||||
alphaSync = func(event.Event) {
|
||||
log.Debug("alphabet keys sync is disabled")
|
||||
}
|
||||
} else {
|
||||
alphaSync = governanceProcessor.HandleAlphabetSync
|
||||
err = bindMainnetProcessor(governanceProcessor, server)
|
||||
if err != nil {
|
||||
|
@ -625,6 +625,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if !withoutMainNet {
|
||||
// create mainnnet neofs processor
|
||||
neofsProcessor, err := neofs.New(&neofs.Params{
|
||||
Log: log,
|
||||
|
@ -650,6 +651,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// create alphabet processor
|
||||
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 (
|
||||
result = new(contracts)
|
||||
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")
|
||||
neofsContractStr := cfg.GetString("contracts.neofs")
|
||||
balanceContractStr := cfg.GetString("contracts.balance")
|
||||
containerContractStr := cfg.GetString("contracts.container")
|
||||
auditContractStr := cfg.GetString("contracts.audit")
|
||||
proxyContractStr := cfg.GetString("contracts.proxy")
|
||||
processingContractStr := cfg.GetString("contracts.processing")
|
||||
reputationContractStr := cfg.GetString("contracts.reputation")
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("ir: can't read reputation script-hash: %w", err)
|
||||
|
|
Loading…
Reference in a new issue