-
Notifications
You must be signed in to change notification settings - Fork 178
/
config.go
34 lines (29 loc) · 1.12 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
package compliance
const MinSkipNewProposalsThreshold = 1000
// Config is shared config for consensus and collection compliance engines, and
// the consensus follower engine.
type Config struct {
// SkipNewProposalsThreshold defines the threshold for dropping blocks that are too far in
// the future. Formally, let `H` be the view of the latest finalized block known to this
// node. A new block `B` is dropped without further processing, if
// B.View > H + SkipNewProposalsThreshold
SkipNewProposalsThreshold uint64
}
func DefaultConfig() Config {
return Config{
SkipNewProposalsThreshold: 100_000,
}
}
type Opt func(*Config)
// WithSkipNewProposalsThreshold returns an option to set the skip new proposals
// threshold. For inputs less than the minimum threshold, the minimum threshold
// will be set instead.
func WithSkipNewProposalsThreshold(threshold uint64) Opt {
return func(config *Config) {
// sanity check: small values are dangerous and can cause finalization halt
if threshold < MinSkipNewProposalsThreshold {
threshold = MinSkipNewProposalsThreshold
}
config.SkipNewProposalsThreshold = threshold
}
}