-
Notifications
You must be signed in to change notification settings - Fork 178
/
config.go
52 lines (43 loc) · 1.51 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
package consensus
import (
"time"
)
type ParticipantConfig struct {
TimeoutInitial time.Duration // the initial timeout for the pacemaker
TimeoutMinimum time.Duration // the minimum timeout for the pacemaker
TimeoutAggregationFraction float64 // the percentage part of the timeout period reserved for vote aggregation
TimeoutIncreaseFactor float64 // the factor at which the timeout grows when timeouts occur
TimeoutDecreaseFactor float64 // the factor at which the timeout grows when timeouts occur
BlockRateDelay time.Duration // a delay to broadcast block proposal in order to control the block production rate
}
type Option func(*ParticipantConfig)
func WithInitialTimeout(timeout time.Duration) Option {
return func(cfg *ParticipantConfig) {
cfg.TimeoutInitial = timeout
}
}
func WithMinTimeout(timeout time.Duration) Option {
return func(cfg *ParticipantConfig) {
cfg.TimeoutMinimum = timeout
}
}
func WithTimeoutIncreaseFactor(factor float64) Option {
return func(cfg *ParticipantConfig) {
cfg.TimeoutIncreaseFactor = factor
}
}
func WithTimeoutDecreaseFactor(factor float64) Option {
return func(cfg *ParticipantConfig) {
cfg.TimeoutDecreaseFactor = factor
}
}
func WithVoteAggregationTimeoutFraction(fraction float64) Option {
return func(cfg *ParticipantConfig) {
cfg.TimeoutAggregationFraction = fraction
}
}
func WithBlockRateDelay(delay time.Duration) Option {
return func(cfg *ParticipantConfig) {
cfg.BlockRateDelay = delay
}
}