Documentation ¶
Index ¶
- Variables
- func PrepareSendReductionTest(hlp *Helper, stepFn consensus.PhaseFn) func(t *testing.T)
- func ShouldProcess(m message.Message, round uint64, step uint8, queue *consensus.Queue) bool
- type Aggregator
- type Handler
- func (b *Handler) AmMember(round uint64, step uint8) bool
- func (b *Handler) Committee(round uint64, step uint8) user.VotingCommittee
- func (b *Handler) IsMember(pubKeyBLS []byte, round uint64, step uint8) bool
- func (b *Handler) Quorum(round uint64) int
- func (b *Handler) VerifySignature(red message.Reduction) error
- func (b *Handler) VotesFor(pubKeyBLS []byte, round uint64, step uint8) int
- type Helper
- func (hlp *Helper) FailOnVerification(flag bool)
- func (hlp *Helper) ProcessCandidateVerificationRequest(blk block.Block) error
- func (hlp *Helper) Spawn(hash []byte, round uint64, step uint8) []message.Reduction
- func (hlp *Helper) Verify(hash []byte, sv message.StepVotes, round uint64, step uint8) error
- type Reduction
- type Result
Constants ¶
This section is empty.
Variables ¶
var EmptyHash [32]byte
EmptyHash ...
var EmptyStepVotes = message.StepVotes{}
EmptyStepVotes ...
Functions ¶
func PrepareSendReductionTest ¶ added in v0.4.0
PrepareSendReductionTest tests that the reduction step completes without problems and produces a StepVotesMsg in case it receives enough valid Reduction messages.
func ShouldProcess ¶ added in v0.4.0
ShouldProcess checks whether a message is consistent with the current round and step. If it is not, it either discards it or stores it for later. The function potentially mutates the consensus.Queue.
Types ¶
type Aggregator ¶ added in v0.4.0
type Aggregator struct {
// contains filtered or unexported fields
}
The Aggregator acts as a de facto storage unit for Reduction messages. Any message it receives will be Aggregated into a StepVotes struct, organized by block hash. Once the key set for a StepVotes of a certain block hash reaches quorum, this StepVotes is passed on to the Reducer by use of the `haltChan` channel. An Aggregator should be instantiated on a per-step basis and is no longer usable after reaching quorum and sending on `haltChan`.
func NewAggregator ¶ added in v0.4.0
func NewAggregator(handler *Handler) *Aggregator
NewAggregator returns an instantiated Aggregator, ready for use by both reduction steps.
func (*Aggregator) CollectVote ¶ added in v0.4.0
func (a *Aggregator) CollectVote(ev message.Reduction) *Result
CollectVote collects a Reduction message, and add its sender public key and signature to the StepVotes/Set kept under the corresponding block hash. If the Set reaches or exceeds quorum, a result is created with the voted hash and the related StepVotes added. The validation of the candidate block is left to the caller.
type Handler ¶ added in v0.2.0
Handler is responsible for performing operations that need to know about specific event fields.
func NewHandler ¶ added in v0.2.0
NewHandler will return a Handler, injected with the passed committee and an unmarshaller which uses the injected validation function.
func (*Handler) Committee ¶ added in v0.2.0
func (b *Handler) Committee(round uint64, step uint8) user.VotingCommittee
Committee returns a VotingCommittee for a given round and step.
func (*Handler) IsMember ¶ added in v0.2.0
IsMember delegates the committee.Handler to check if a BLS public key belongs to a committee for the specified round and step.
func (*Handler) Quorum ¶ added in v0.2.0
Quorum returns the amount of committee votes to reach a quorum.
func (*Handler) VerifySignature ¶ added in v0.2.0
VerifySignature verifies the BLS signature of the Reduction event. Since the payload is nil, verifying the signature equates to verifying solely the Header.
type Helper ¶ added in v0.2.0
type Helper struct { *consensus.Emitter ThisSender []byte ProvisionersKeys []key.Keys P *user.Provisioners Nr int Handler *Handler // contains filtered or unexported fields }
Helper for reducing test boilerplate.
func (*Helper) FailOnVerification ¶ added in v0.4.0
FailOnVerification tells the RPC bus to return an error.
func (*Helper) ProcessCandidateVerificationRequest ¶ added in v0.4.0
ProcessCandidateVerificationRequest is a callback used by the firststep reduction to verify potential winning candidates.
type Reduction ¶
Reduction is a struct to be embedded in the reduction steps.
func (*Reduction) IncreaseTimeout ¶ added in v0.4.0
IncreaseTimeout is used when reduction does not reach the quorum or converges over an empty block.