[#718] ir: Do not require processing hash in main notary disabled mode

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-07-22 21:33:10 +03:00 committed by Alex Vanin
parent e753eebaee
commit c41ec2e2e9

View file

@ -319,7 +319,12 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
withoutMainNet := cfg.GetBool("without_mainnet") withoutMainNet := cfg.GetBool("without_mainnet")
// get all script hashes of contracts // get all script hashes of contracts
server.contracts, err = parseContracts(cfg, withoutMainNet, server.sideNotaryConfig.disabled) server.contracts, err = parseContracts(
cfg,
withoutMainNet,
server.mainNotaryConfig.disabled,
server.sideNotaryConfig.disabled,
)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -851,7 +856,7 @@ func createClient(ctx context.Context, p *chainParams, notaryOpts ...client.Nota
) )
} }
func parseContracts(cfg *viper.Viper, withoutMainNet, withoutNotary bool) (*contracts, error) { func parseContracts(cfg *viper.Viper, withoutMainNet, withoutMainNotary, withoutSideNotary bool) (*contracts, error) {
var ( var (
result = new(contracts) result = new(contracts)
err error err error
@ -863,13 +868,15 @@ func parseContracts(cfg *viper.Viper, withoutMainNet, withoutNotary bool) (*cont
return nil, fmt.Errorf("ir: can't read neofs script-hash: %w", err) return nil, fmt.Errorf("ir: can't read neofs script-hash: %w", err)
} }
result.processing, err = util.Uint160DecodeStringLE(cfg.GetString("contracts.processing")) if !withoutMainNotary {
if err != nil { result.processing, err = util.Uint160DecodeStringLE(cfg.GetString("contracts.processing"))
return nil, fmt.Errorf("ir: can't read processing script-hash: %w", err) if err != nil {
return nil, fmt.Errorf("ir: can't read processing script-hash: %w", err)
}
} }
} }
if !withoutNotary { if !withoutSideNotary {
result.proxy, err = util.Uint160DecodeStringLE(cfg.GetString("contracts.proxy")) result.proxy, err = util.Uint160DecodeStringLE(cfg.GetString("contracts.proxy"))
if err != nil { if err != nil {
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)