mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 13:41:37 +00:00
oracle: specify neofs timeout as timeout, set default if 0
There has to be some sane default and we'd like configuration to be consistent with other timeout values.
This commit is contained in:
parent
f69fd34220
commit
7a1c1638e4
3 changed files with 6 additions and 3 deletions
|
@ -18,6 +18,6 @@ type OracleConfiguration struct {
|
|||
|
||||
// NeoFSConfiguration is a config for the NeoFS service.
|
||||
type NeoFSConfiguration struct {
|
||||
Nodes []string `yaml:"Nodes"`
|
||||
Timeout int `yaml:"Timeout"`
|
||||
Nodes []string `yaml:"Nodes"`
|
||||
Timeout time.Duration `yaml:"Timeout"`
|
||||
}
|
||||
|
|
|
@ -108,6 +108,9 @@ func NewOracle(cfg Config) (*Oracle, error) {
|
|||
if o.MainCfg.RequestTimeout == 0 {
|
||||
o.MainCfg.RequestTimeout = defaultRequestTimeout
|
||||
}
|
||||
if o.MainCfg.NeoFS.Timeout == 0 {
|
||||
o.MainCfg.NeoFS.Timeout = defaultRequestTimeout
|
||||
}
|
||||
if o.MainCfg.MaxConcurrentRequests == 0 {
|
||||
o.MainCfg.MaxConcurrentRequests = defaultMaxConcurrentRequests
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ func (o *Oracle) processRequest(priv *keys.PrivateKey, req request) error {
|
|||
resp.Code = transaction.Error
|
||||
}
|
||||
case neofs.URIScheme:
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(o.MainCfg.NeoFS.Timeout)*time.Millisecond)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), o.MainCfg.NeoFS.Timeout)
|
||||
defer cancel()
|
||||
index := (int(req.ID) + incTx.attempts) % len(o.MainCfg.NeoFS.Nodes)
|
||||
res, err := neofs.Get(ctx, priv, u, o.MainCfg.NeoFS.Nodes[index])
|
||||
|
|
Loading…
Reference in a new issue