github.com/koko1123/flow-go-1@v0.29.6/module/compliance/config.go (about)

     1  package compliance
     2  
     3  const MinSkipNewProposalsThreshold = 1000
     4  
     5  // Config is shared config for consensus and collection compliance engines, and
     6  // the consensus follower engine.
     7  type Config struct {
     8  	// SkipNewProposalsThreshold defines the threshold where, if we observe a new
     9  	// proposal which is this far behind our local latest finalized, we drop the
    10  	// proposal rather than cache it.
    11  	SkipNewProposalsThreshold uint64
    12  }
    13  
    14  func DefaultConfig() Config {
    15  	return Config{
    16  		SkipNewProposalsThreshold: 100_000,
    17  	}
    18  }
    19  
    20  type Opt func(*Config)
    21  
    22  // WithSkipNewProposalsThreshold returns an option to set the skip new proposals
    23  // threshold. For inputs less than the minimum threshold, the minimum threshold
    24  // will be set instead.
    25  func WithSkipNewProposalsThreshold(threshold uint64) Opt {
    26  	return func(config *Config) {
    27  		// sanity check: small values are dangerous and can cause finalization halt
    28  		if threshold < MinSkipNewProposalsThreshold {
    29  			threshold = MinSkipNewProposalsThreshold
    30  		}
    31  		config.SkipNewProposalsThreshold = threshold
    32  	}
    33  }