[#706] ir: Do not require proxy hash in notary disabled mode

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-07-21 15:21:20 +03:00 committed by Alex Vanin
parent a2cb9cbc49
commit 795c49d16b

View file

@ -306,7 +306,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
withoutMainNet := cfg.GetBool("without_mainnet")
// get all script hashes of contracts
server.contracts, err = parseContracts(cfg, withoutMainNet)
server.contracts, err = parseContracts(cfg, withoutMainNet, server.sideNotaryConfig.disabled)
if err != nil {
return nil, err
}
@ -828,7 +828,7 @@ func createClient(ctx context.Context, p *chainParams, notaryOpts ...client.Nota
)
}
func parseContracts(cfg *viper.Viper, withoutMainNet bool) (*contracts, error) {
func parseContracts(cfg *viper.Viper, withoutMainNet, withoutNotary bool) (*contracts, error) {
var (
result = new(contracts)
err error
@ -846,11 +846,17 @@ func parseContracts(cfg *viper.Viper, withoutMainNet bool) (*contracts, error) {
}
}
if !withoutNotary {
result.proxy, err = util.Uint160DecodeStringLE(cfg.GetString("contracts.proxy"))
if err != nil {
return nil, fmt.Errorf("ir: can't read proxy script-hash: %w", err)
}
}
netmapContractStr := cfg.GetString("contracts.netmap")
balanceContractStr := cfg.GetString("contracts.balance")
containerContractStr := cfg.GetString("contracts.container")
auditContractStr := cfg.GetString("contracts.audit")
proxyContractStr := cfg.GetString("contracts.proxy")
reputationContractStr := cfg.GetString("contracts.reputation")
neofsIDContractStr := cfg.GetString("contracts.neofsid")
@ -874,11 +880,6 @@ func parseContracts(cfg *viper.Viper, withoutMainNet bool) (*contracts, error) {
return nil, fmt.Errorf("ir: can't read audit script-hash: %w", err)
}
result.proxy, err = util.Uint160DecodeStringLE(proxyContractStr)
if err != nil {
return nil, fmt.Errorf("ir: can't read proxy 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)