This repository has been archived by the owner on May 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
config.go
69 lines (56 loc) · 2.23 KB
/
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
65
66
67
68
69
package client
import (
"time"
configtime "github.com/keep-network/keep-ecdsa/config/time"
)
const (
// The default look-back period to check if existing, active keeps are awaiting
// signer generation. When the client starts, it goes through all keeps
// registered on-chain to check whether it's a member of one of them and to
// generate the signing key if needed. The client does not check keeps older
// than the awaiting key generation lookback value allows to minimize the
// number of calls to the chain calls.
defaultAwaitingKeyGenerationLookback = 24 * time.Hour
// The default value of a timeout for a keep key generation.
defaultKeyGenerationTimeout = 3 * time.Hour
// The default value of a timeout for a signature calculation.
defaultSigningTimeout = 2 * time.Hour
)
// Config contains configuration for tss protocol execution.
type Config struct {
// Defines the look-back period to check if existing, active keeps are awaiting
// signer generation on the client start. The client does not check keeps older
// than the look-back value.
AwaitingKeyGenerationLookback configtime.Duration
// Timeout for key generation and signature calculation.
KeyGenerationTimeout configtime.Duration
SigningTimeout configtime.Duration
}
// GetAwaitingKeyGenerationLookback returns a look-back period to check if
// existing, active keeps are awaiting signer generation. If a value is not set
// it returns a default value.
func (c *Config) GetAwaitingKeyGenerationLookback() time.Duration {
lookbackPeriod := c.AwaitingKeyGenerationLookback.ToDuration()
if lookbackPeriod == 0 {
lookbackPeriod = defaultAwaitingKeyGenerationLookback
}
return lookbackPeriod
}
// GetKeyGenerationTimeout returns key generation timeout. If a value is not set
// it returns a default value.
func (c *Config) GetKeyGenerationTimeout() time.Duration {
timeout := c.KeyGenerationTimeout.ToDuration()
if timeout == 0 {
timeout = defaultKeyGenerationTimeout
}
return timeout
}
// GetSigningTimeout returns signature calculation timeout. If a value is not set
// it returns a default value.
func (c *Config) GetSigningTimeout() time.Duration {
timeout := c.SigningTimeout.ToDuration()
if timeout == 0 {
timeout = defaultSigningTimeout
}
return timeout
}