-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
ocr2_config.go
64 lines (52 loc) · 1.98 KB
/
ocr2_config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package config
import (
"time"
"github.com/pkg/errors"
"github.com/smartcontractkit/chainlink/core/config/envvar"
"github.com/smartcontractkit/chainlink/core/config/parse"
"github.com/smartcontractkit/chainlink/core/store/models"
)
// OCR2Config is a subset of global config relevant to OCR v2.
type OCR2Config interface {
// OCR2 config, can override in jobs, all chains
OCR2ContractConfirmations() uint16
OCR2ContractTransmitterTransmitTimeout() time.Duration
OCR2BlockchainTimeout() time.Duration
OCR2DatabaseTimeout() time.Duration
OCR2ContractPollInterval() time.Duration
OCR2ContractSubscribeInterval() time.Duration
OCR2KeyBundleID() (string, error)
// OCR2 config, cannot override in jobs
OCR2TraceLogging() bool
}
func (c *generalConfig) OCR2ContractConfirmations() uint16 {
return getEnvWithFallback(c, envvar.NewUint16("OCR2ContractConfirmations"))
}
func (c *generalConfig) OCR2ContractPollInterval() time.Duration {
return c.getDuration("OCR2ContractPollInterval")
}
func (c *generalConfig) OCR2ContractSubscribeInterval() time.Duration {
return c.getDuration("OCR2ContractSubscribeInterval")
}
func (c *generalConfig) OCR2ContractTransmitterTransmitTimeout() time.Duration {
return c.getWithFallback("OCR2ContractTransmitterTransmitTimeout", parse.Duration).(time.Duration)
}
func (c *generalConfig) OCR2BlockchainTimeout() time.Duration {
return c.getDuration("OCR2BlockchainTimeout")
}
func (c *generalConfig) OCR2DatabaseTimeout() time.Duration {
return c.getWithFallback("OCR2DatabaseTimeout", parse.Duration).(time.Duration)
}
func (c *generalConfig) OCR2KeyBundleID() (string, error) {
kbStr := c.viper.GetString(envvar.Name("OCR2KeyBundleID"))
if kbStr != "" {
_, err := models.Sha256HashFromHex(kbStr)
if err != nil {
return "", errors.Wrapf(ErrEnvInvalid, "OCR_KEY_BUNDLE_ID is an invalid sha256 hash hex string %v", err)
}
}
return kbStr, nil
}
func (c *generalConfig) OCR2TraceLogging() bool {
return c.viper.GetBool(envvar.Name("OCRTraceLogging"))
}