github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/consensus/hotstuff/notifications/noop_consumer.go (about) 1 package notifications 2 3 import ( 4 "time" 5 6 "github.com/onflow/flow-go/consensus/hotstuff" 7 "github.com/onflow/flow-go/consensus/hotstuff/model" 8 "github.com/onflow/flow-go/model/flow" 9 ) 10 11 // NoopConsumer is an implementation of the notifications consumer that 12 // doesn't do anything. 13 type NoopConsumer struct { 14 NoopProposalViolationConsumer 15 NoopFinalizationConsumer 16 NoopParticipantConsumer 17 NoopCommunicatorConsumer 18 } 19 20 var _ hotstuff.Consumer = (*NoopConsumer)(nil) 21 22 func NewNoopConsumer() *NoopConsumer { 23 nc := &NoopConsumer{} 24 return nc 25 } 26 27 // no-op implementation of hotstuff.Consumer(but not nested interfaces) 28 29 type NoopParticipantConsumer struct{} 30 31 func (*NoopParticipantConsumer) OnEventProcessed() {} 32 33 func (*NoopParticipantConsumer) OnStart(uint64) {} 34 35 func (*NoopParticipantConsumer) OnReceiveProposal(uint64, *model.Proposal) {} 36 37 func (*NoopParticipantConsumer) OnReceiveQc(uint64, *flow.QuorumCertificate) {} 38 39 func (*NoopParticipantConsumer) OnReceiveTc(uint64, *flow.TimeoutCertificate) {} 40 41 func (*NoopParticipantConsumer) OnPartialTc(uint64, *hotstuff.PartialTcCreated) {} 42 43 func (*NoopParticipantConsumer) OnLocalTimeout(uint64) {} 44 45 func (*NoopParticipantConsumer) OnViewChange(uint64, uint64) {} 46 47 func (*NoopParticipantConsumer) OnQcTriggeredViewChange(uint64, uint64, *flow.QuorumCertificate) {} 48 49 func (*NoopParticipantConsumer) OnTcTriggeredViewChange(uint64, uint64, *flow.TimeoutCertificate) {} 50 51 func (*NoopParticipantConsumer) OnStartingTimeout(model.TimerInfo) {} 52 53 func (*NoopParticipantConsumer) OnCurrentViewDetails(uint64, uint64, flow.Identifier) {} 54 55 // no-op implementation of hotstuff.FinalizationConsumer 56 57 type NoopFinalizationConsumer struct{} 58 59 var _ hotstuff.FinalizationConsumer = (*NoopFinalizationConsumer)(nil) 60 61 func (*NoopFinalizationConsumer) OnBlockIncorporated(*model.Block) {} 62 63 func (*NoopFinalizationConsumer) OnFinalizedBlock(*model.Block) {} 64 65 // no-op implementation of hotstuff.TimeoutCollectorConsumer 66 67 type NoopTimeoutCollectorConsumer struct{} 68 69 var _ hotstuff.TimeoutCollectorConsumer = (*NoopTimeoutCollectorConsumer)(nil) 70 71 func (*NoopTimeoutCollectorConsumer) OnTcConstructedFromTimeouts(*flow.TimeoutCertificate) {} 72 73 func (*NoopTimeoutCollectorConsumer) OnPartialTcCreated(uint64, *flow.QuorumCertificate, *flow.TimeoutCertificate) { 74 } 75 76 func (*NoopTimeoutCollectorConsumer) OnNewQcDiscovered(*flow.QuorumCertificate) {} 77 78 func (*NoopTimeoutCollectorConsumer) OnNewTcDiscovered(*flow.TimeoutCertificate) {} 79 80 func (*NoopTimeoutCollectorConsumer) OnTimeoutProcessed(*model.TimeoutObject) {} 81 82 // no-op implementation of hotstuff.CommunicatorConsumer 83 84 type NoopCommunicatorConsumer struct{} 85 86 var _ hotstuff.CommunicatorConsumer = (*NoopCommunicatorConsumer)(nil) 87 88 func (*NoopCommunicatorConsumer) OnOwnVote(flow.Identifier, uint64, []byte, flow.Identifier) {} 89 90 func (*NoopCommunicatorConsumer) OnOwnTimeout(*model.TimeoutObject) {} 91 92 func (*NoopCommunicatorConsumer) OnOwnProposal(*flow.Header, time.Time) {} 93 94 // no-op implementation of hotstuff.VoteCollectorConsumer 95 96 type NoopVoteCollectorConsumer struct{} 97 98 var _ hotstuff.VoteCollectorConsumer = (*NoopVoteCollectorConsumer)(nil) 99 100 func (*NoopVoteCollectorConsumer) OnQcConstructedFromVotes(*flow.QuorumCertificate) {} 101 102 func (*NoopVoteCollectorConsumer) OnVoteProcessed(*model.Vote) {} 103 104 // no-op implementation of hotstuff.ProposalViolationConsumer 105 106 type NoopProposalViolationConsumer struct{} 107 108 var _ hotstuff.ProposalViolationConsumer = (*NoopProposalViolationConsumer)(nil) 109 110 func (*NoopProposalViolationConsumer) OnInvalidBlockDetected(flow.Slashable[model.InvalidProposalError]) { 111 } 112 113 func (*NoopProposalViolationConsumer) OnDoubleProposeDetected(*model.Block, *model.Block) {} 114 115 func (*NoopProposalViolationConsumer) OnDoubleVotingDetected(*model.Vote, *model.Vote) {} 116 117 func (*NoopProposalViolationConsumer) OnInvalidVoteDetected(model.InvalidVoteError) {} 118 119 func (*NoopProposalViolationConsumer) OnVoteForInvalidBlockDetected(*model.Vote, *model.Proposal) {} 120 121 func (*NoopProposalViolationConsumer) OnDoubleTimeoutDetected(*model.TimeoutObject, *model.TimeoutObject) { 122 } 123 124 func (*NoopProposalViolationConsumer) OnInvalidTimeoutDetected(model.InvalidTimeoutError) {}