Documentation ¶
Index ¶
- func MarshalScore(r *bytes.Buffer, ev wire.Event) error
- func MockSelectionEventBuffer(hash []byte) *bytes.Buffer
- func UnmarshalScore(r *bytes.Buffer, ev wire.Event) error
- type Factory
- type Handler
- type Helper
- type Score
- type ScoreHandler
- type Selector
- func (s *Selector) CollectGeneration(e consensus.Event) error
- func (s *Selector) CollectScoreEvent(e consensus.Event) error
- func (s *Selector) Finalize()
- func (s *Selector) ID() uint32
- func (s *Selector) IncreaseTimeOut()
- func (s *Selector) Initialize(eventPlayer consensus.EventPlayer, signer consensus.Signer, ...) []consensus.TopicListener
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalScore ¶ added in v0.2.0
MarshalScore the buffer into a committee Event Field order is the following: * Blind Bid Fields [Score, Proof, Z, BidList, Seed, Candidate Block Hash]
func MockSelectionEventBuffer ¶
MockSelectionEventBuffer mocks a Selection event, marshals it, and returns the resulting buffer.
Types ¶
type Factory ¶ added in v0.2.0
Factory creates the selection component.
func NewFactory ¶ added in v0.2.0
NewFactory instantiates a Factory.
func (*Factory) Instantiate ¶ added in v0.2.0
Instantiate a Selector and return it. Implements consensus.ComponentFactory.
type Handler ¶ added in v0.2.0
type Handler interface { Verify(Score) error ResetThreshold() LowerThreshold() Priority(Score, Score) bool }
Handler is an abstraction of the selection component event handler. It is primarily used for testing purposes, to bypass the zkproof verification.
type Helper ¶ added in v0.2.0
type Helper struct { *Factory BidList user.BidList Selector *Selector *consensus.SimplePlayer BestScoreChan chan bytes.Buffer // contains filtered or unexported fields }
Helper for reducing selection test boilerplate
func (*Helper) GenerateEd25519Fields ¶ added in v0.2.0
GenerateEd25519Fields will return the Ed25519 header fields for a given consensus event.
func (*Helper) Initialize ¶ added in v0.2.0
func (h *Helper) Initialize(ru consensus.RoundUpdate)
Initialize the selector with the given round update.
func (*Helper) SendBatch ¶ added in v0.2.0
SendBatch generates a batch of score events and sends them to the selector.
func (*Helper) SetHandler ¶ added in v0.2.0
SetHandler sets the handler on the Selector. Used for bypassing zkproof verification calls during tests.
func (*Helper) StartSelection ¶ added in v0.2.0
func (h *Helper) StartSelection()
StartSelection forces the Selector to start the selection
type Score ¶ added in v0.2.0
type Score struct { Score []byte Proof []byte Z []byte BidListSubset []byte PrevHash []byte Seed []byte VoteHash []byte }
Score represents the Score Message with the fields consistent with the Blind Bid data structure
func MockSelectionEvent ¶
MockSelectionEvent mocks a Selection event and returns it.
type ScoreHandler ¶ added in v0.2.0
type ScoreHandler struct {
// contains filtered or unexported fields
}
func NewScoreHandler ¶ added in v0.2.0
func NewScoreHandler(bidList user.BidList) *ScoreHandler
func (*ScoreHandler) LowerThreshold ¶ added in v0.2.0
func (sh *ScoreHandler) LowerThreshold()
func (*ScoreHandler) Priority ¶ added in v0.2.0
func (sh *ScoreHandler) Priority(first, second Score) bool
Priority returns true if the first element has priority over the second, false otherwise
func (*ScoreHandler) ResetThreshold ¶ added in v0.2.0
func (sh *ScoreHandler) ResetThreshold()
func (*ScoreHandler) Verify ¶ added in v0.2.0
func (sh *ScoreHandler) Verify(m Score) error
type Selector ¶ added in v0.2.0
type Selector struct {
// contains filtered or unexported fields
}
Selector is the component responsible for collecting score events and propagating the best one after a timeout.
func NewComponent ¶ added in v0.2.0
NewComponent creates and launches the component which responsibility is to validate and select the best score among the blind bidders. The component publishes under the topic BestScoreTopic
func (*Selector) CollectGeneration ¶ added in v0.2.0
CollectGeneration signals the selection start by triggering `EventPlayer.Play`
func (*Selector) CollectScoreEvent ¶ added in v0.2.0
CollectScoreEvent checks the score of an incoming Event and, in case it has a higher score, verifies, propagates and saves it
func (*Selector) Finalize ¶ added in v0.2.0
func (s *Selector) Finalize()
Finalize pauses event streaming and stops the timer. Implements consensus.Component.
func (*Selector) ID ¶ added in v0.2.0
ID returns the ID of the Score message Listener. Implements consensus.Component
func (*Selector) IncreaseTimeOut ¶ added in v0.2.0
func (s *Selector) IncreaseTimeOut()
IncreaseTimeOut increases the timeout after a failed selection
func (*Selector) Initialize ¶ added in v0.2.0
func (s *Selector) Initialize(eventPlayer consensus.EventPlayer, signer consensus.Signer, r consensus.RoundUpdate) []consensus.TopicListener
Initialize the Selector, by creating the handler and returning the needed Listeners. Implements consensus.Component.