Documentation ¶
Index ¶
- Constants
- func CreateCommitteeVoteSet(p *user.Provisioners, k []key.ConsensusKeys, hash []byte, committeeSize int, ...) []consensus.Event
- func Marshal(r *bytes.Buffer, a Agreement) error
- func MarshalStepVotes(r *bytes.Buffer, vote *StepVotes) error
- func MarshalVotes(r *bytes.Buffer, votes []*StepVotes) error
- func MockAgreement(hash []byte, round uint64, step uint8, keys []key.ConsensusKeys, ...) *bytes.Buffer
- func MockConsensusEvent(hash []byte, round uint64, step uint8, keys []key.ConsensusKeys, ...) consensus.Event
- func MockWire(hash []byte, round uint64, step uint8, keys []key.ConsensusKeys, ...) *bytes.Buffer
- func ReconstructApk(subcommittee sortedset.Set) (*bls.Apk, error)
- func Sign(a *Agreement, keys key.ConsensusKeys) error
- func Unmarshal(r *bytes.Buffer, a *Agreement) error
- func UnmarshalVotes(r *bytes.Buffer, votes []*StepVotes) error
- type Accumulator
- type Agreement
- type Factory
- type Handler
- type Helper
- type StepVotes
Constants ¶
const MaxCommitteeSize = 64
Variables ¶
This section is empty.
Functions ¶
func CreateCommitteeVoteSet ¶ added in v0.2.0
func CreateCommitteeVoteSet(p *user.Provisioners, k []key.ConsensusKeys, hash []byte, committeeSize int, round uint64, step uint8) []consensus.Event
func MarshalStepVotes ¶
MarshalStepVotes marshals the aggregated form of the BLS PublicKey and Signature for an ordered set of votes
func MarshalVotes ¶
MarshalVotes marshals an array of StepVotes
func MockAgreement ¶
func MockAgreement(hash []byte, round uint64, step uint8, keys []key.ConsensusKeys, p *user.Provisioners, i ...int) *bytes.Buffer
MockAgreement mocks an Agreement event, and returns the marshalled representation of it as a `*bytes.Buffer`. The `i` parameter is used to diversify the mocks to avoid duplicates NOTE: it does not include the topic nor the Header
func MockConsensusEvent ¶ added in v0.2.0
func MockConsensusEvent(hash []byte, round uint64, step uint8, keys []key.ConsensusKeys, p *user.Provisioners, i ...int) consensus.Event
MockConsensusEvent mocks a consensus.Event with an Agreement payload.
func MockWire ¶ added in v0.2.0
func MockWire(hash []byte, round uint64, step uint8, keys []key.ConsensusKeys, p *user.Provisioners, i ...int) *bytes.Buffer
MockWire creates a buffer representing an Agreement travelling to other Provisioners
func ReconstructApk ¶
ReconstructApk reconstructs an aggregated BLS public key from a subcommittee.
func Sign ¶
func Sign(a *Agreement, keys key.ConsensusKeys) error
Sign signs an aggregated agreement event
Types ¶
type Accumulator ¶ added in v0.2.0
type Accumulator struct { CollectedVotesChan chan []Agreement // contains filtered or unexported fields }
Accumulator is an event accumulator, that will accumulate events until it reaches a certain threshold.
func (*Accumulator) Accumulate ¶ added in v0.2.0
func (a *Accumulator) Accumulate()
Accumulate agreements per block hash until a quorum is reached or a stop is detected (by closing the internal event channel). Supposed to run in a goroutine
func (*Accumulator) CreateWorkers ¶ added in v0.2.0
func (a *Accumulator) CreateWorkers(amount int)
func (*Accumulator) Process ¶ added in v0.2.0
func (a *Accumulator) Process(ev Agreement)
Process a received Event, by passing it to a worker in the worker pool (if the event sender is part of the voting committee).
func (*Accumulator) Stop ¶ added in v0.2.0
func (a *Accumulator) Stop()
Stop kills the thread pool and shuts down the Accumulator.
type Agreement ¶
type Agreement struct { header.Header VotesPerStep []*StepVotes // contains filtered or unexported fields }
Agreement is the Event created at the end of the Reduction process. It includes the aggregated compressed signatures of all voters
func MockAgreementEvent ¶
func MockAgreementEvent(hash []byte, round uint64, step uint8, keys []key.ConsensusKeys, p *user.Provisioners, iterativeIdx ...int) *Agreement
MockAgreementEvent returns a mocked Agreement Event, to be used for testing purposes. It includes a vararg iterativeIdx to help avoiding duplicates when testing
func (*Agreement) SetSignature ¶ added in v0.2.0
func (Agreement) SignedVotes ¶
type Factory ¶ added in v0.2.0
type Factory struct {
// contains filtered or unexported fields
}
Factory creates the agreement component.
func NewFactory ¶ added in v0.2.0
func NewFactory(publisher eventbus.Publisher, keys key.ConsensusKeys) *Factory
NewFactory instantiates a Factory.
func (*Factory) Instantiate ¶ added in v0.2.0
Instantiate an agreement component and return it. Implements consensus.ComponentFactory.
type Handler ¶ added in v0.2.0
type Handler interface { AmMember(uint64, uint8) bool IsMember([]byte, uint64, uint8) bool Committee(uint64, uint8) user.VotingCommittee Quorum(uint64) int VotesFor([]byte, uint64, uint8) int Verify(Agreement) error }
Handler interface is handy for tests
type Helper ¶ added in v0.2.0
type Helper struct { Bus *eventbus.EventBus P *user.Provisioners Keys []key.ConsensusKeys Aggro *agreement CertificateChan chan bytes.Buffer // contains filtered or unexported fields }
Helper is a struct that facilitates sending semi-real Events with minimum effort
func LaunchHelper ¶ added in v0.2.0
func ProduceWinningHash ¶ added in v0.2.0
ProduceWinningHash is used to produce enough valid Events to reach Quorum and trigger sending a winning hash to the channel
func (*Helper) Initialize ¶ added in v0.2.0
func (hlp *Helper) Initialize(ru consensus.RoundUpdate)
Initialize the Agreement with a Round update
type StepVotes ¶
StepVotes represents the aggregated votes for one reduction step. Normally an Agreement event includes two of these structures. They need to be kept separated since the BitSet representation of the Signees does not admit duplicates, whereas the same provisioner may very well be included in the committee for both Reduction steps
func GenVotes ¶
func GenVotes(hash []byte, round uint64, step uint8, keys []key.ConsensusKeys, p *user.Provisioners) []*StepVotes
GenVotes randomly generates a slice of StepVotes with the indicated lenght. Albeit random, the generation is consistent with the rules of Votes
func NewStepVotes ¶
func NewStepVotes() *StepVotes
NewStepVotes returns a new StepVotes structure for a given round, step and block hash
func UnmarshalStepVotes ¶
UnmarshalStepVotes unmarshals a single StepVote