github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/consensus/hotstuff/integration/options_test.go (about) 1 package integration 2 3 import ( 4 "errors" 5 6 "github.com/onflow/flow-go/consensus/hotstuff/pacemaker/timeout" 7 "github.com/onflow/flow-go/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 IncomingTimeoutObjects TimeoutObjectFilter 22 OutgoingTimeoutObjects TimeoutObjectFilter 23 IncomingProposals ProposalFilter 24 OutgoingProposals ProposalFilter 25 26 StopCondition Condition 27 } 28 29 func WithRoot(root *flow.Header) Option { 30 return func(cfg *Config) { 31 cfg.Root = root 32 } 33 } 34 35 func WithParticipants(participants flow.IdentityList) Option { 36 return func(cfg *Config) { 37 cfg.Participants = participants 38 } 39 } 40 41 func WithLocalID(localID flow.Identifier) Option { 42 return func(cfg *Config) { 43 cfg.LocalID = localID 44 } 45 } 46 47 func WithTimeouts(timeouts timeout.Config) Option { 48 return func(cfg *Config) { 49 cfg.Timeouts = timeouts 50 } 51 } 52 53 func WithIncomingVotes(Filter VoteFilter) Option { 54 return func(cfg *Config) { 55 cfg.IncomingVotes = Filter 56 } 57 } 58 59 func WithOutgoingVotes(Filter VoteFilter) Option { 60 return func(cfg *Config) { 61 cfg.OutgoingVotes = Filter 62 } 63 } 64 65 func WithIncomingProposals(Filter ProposalFilter) Option { 66 return func(cfg *Config) { 67 cfg.IncomingProposals = Filter 68 } 69 } 70 71 func WithOutgoingProposals(Filter ProposalFilter) Option { 72 return func(cfg *Config) { 73 cfg.OutgoingProposals = Filter 74 } 75 } 76 77 func WithIncomingTimeoutObjects(Filter TimeoutObjectFilter) Option { 78 return func(cfg *Config) { 79 cfg.IncomingTimeoutObjects = Filter 80 } 81 } 82 83 func WithOutgoingTimeoutObjects(Filter TimeoutObjectFilter) Option { 84 return func(cfg *Config) { 85 cfg.OutgoingTimeoutObjects = Filter 86 } 87 } 88 89 func WithStopCondition(stop Condition) Option { 90 return func(cfg *Config) { 91 cfg.StopCondition = stop 92 } 93 }