github.com/koko1123/flow-go-1@v0.29.6/consensus/hotstuff/integration/options_test.go (about)

     1  package integration
     2  
     3  import (
     4  	"errors"
     5  
     6  	"github.com/koko1123/flow-go-1/consensus/hotstuff/pacemaker/timeout"
     7  	"github.com/koko1123/flow-go-1/model/flow"
     8  )
     9  
    10  var errStopCondition = errors.New("stop condition reached")
    11  
    12  type Option func(*Config)
    13  
    14  type Config struct {
    15  	Root              *flow.Header
    16  	Participants      flow.IdentityList
    17  	LocalID           flow.Identifier
    18  	Timeouts          timeout.Config
    19  	IncomingVotes     VoteFilter
    20  	OutgoingVotes     VoteFilter
    21  	IncomingProposals ProposalFilter
    22  	OutgoingProposals ProposalFilter
    23  	StopCondition     Condition
    24  }
    25  
    26  func WithRoot(root *flow.Header) Option {
    27  	return func(cfg *Config) {
    28  		cfg.Root = root
    29  	}
    30  }
    31  
    32  func WithParticipants(participants flow.IdentityList) Option {
    33  	return func(cfg *Config) {
    34  		cfg.Participants = participants
    35  	}
    36  }
    37  
    38  func WithLocalID(localID flow.Identifier) Option {
    39  	return func(cfg *Config) {
    40  		cfg.LocalID = localID
    41  	}
    42  }
    43  
    44  func WithTimeouts(timeouts timeout.Config) Option {
    45  	return func(cfg *Config) {
    46  		cfg.Timeouts = timeouts
    47  	}
    48  }
    49  
    50  func WithIncomingVotes(Filter VoteFilter) Option {
    51  	return func(cfg *Config) {
    52  		cfg.IncomingVotes = Filter
    53  	}
    54  }
    55  
    56  func WithOutgoingVotes(Filter VoteFilter) Option {
    57  	return func(cfg *Config) {
    58  		cfg.OutgoingVotes = Filter
    59  	}
    60  }
    61  
    62  func WithIncomingProposals(Filter ProposalFilter) Option {
    63  	return func(cfg *Config) {
    64  		cfg.IncomingProposals = Filter
    65  	}
    66  }
    67  
    68  func WithOutgoingProposals(Filter ProposalFilter) Option {
    69  	return func(cfg *Config) {
    70  		cfg.OutgoingProposals = Filter
    71  	}
    72  }
    73  
    74  func WithStopCondition(stop Condition) Option {
    75  	return func(cfg *Config) {
    76  		cfg.StopCondition = stop
    77  	}
    78  }