Documentation ¶
Index ¶
- func InitAcceptedBlockUpdate(subscriber eventbus.Subscriber) (chan block.Block, uint32)
- func MockMember(keys key.Keys) *user.Member
- func MockNewBlockMsg(t *testing.T, hdr *header.Header) message.Message
- func MockProvisioners(amount int) (*user.Provisioners, []key.Keys)
- func WithFields(round uint64, step uint8, eventName string, hash, blsPubKey []byte, ...) *log.Entry
- type CandidateVerificationFunc
- type ControlFn
- type Controller
- type Emitter
- type ExecuteTxsFunc
- type InternalPacket
- type Phase
- type PhaseFn
- type Publisher
- type Queue
- type Results
- type RoundUpdate
- type TestCallback
- type TestPhase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitAcceptedBlockUpdate ¶
func InitAcceptedBlockUpdate(subscriber eventbus.Subscriber) (chan block.Block, uint32)
InitAcceptedBlockUpdate init listener to get updates about lastly accepted block in the chain.
func MockMember ¶ added in v0.2.0
MockMember mocks a Provisioner.
func MockNewBlockMsg ¶ added in v0.4.4
MockNewBlockMsg ...
func MockProvisioners ¶ added in v0.2.0
func MockProvisioners(amount int) (*user.Provisioners, []key.Keys)
MockProvisioners mock a Provisioner set.
func WithFields ¶ added in v0.4.4
func WithFields(round uint64, step uint8, eventName string, hash, blsPubKey []byte, sVotingCommittee *user.VotingCommittee, sVotedCommittee *sortedset.Cluster, p *user.Provisioners) *log.Entry
WithFields builds a list of common Consensus logging fields. It also adds extra fields for TraceLevel only.
Types ¶
type CandidateVerificationFunc ¶ added in v0.4.0
CandidateVerificationFunc is a callback used to verify candidate blocks after the conclusion of the first reduction step.
type ControlFn ¶ added in v0.4.0
type ControlFn func(context.Context, *Queue, <-chan message.Message, <-chan message.Message, RoundUpdate) Results
ControlFn represents the asynchronous loop controlling the commencement of the Phase transition.
type Controller ¶ added in v0.4.0
type Controller interface { // GetControlFn returns a ControlFn. GetControlFn() ControlFn }
Controller is a factory for the ControlFn. It basically relates to the Agreement, which needs a different execution each round.
type Emitter ¶ added in v0.4.0
type Emitter struct { EventBus *eventbus.EventBus RPCBus *rpcbus.RPCBus Keys key.Keys TimerLength time.Duration }
Emitter is a simple struct to pass the communication channels that the steps should be able to emit onto.
func MockEmitter ¶ added in v0.4.0
MockEmitter is a utility to quickly wire up an emitter in tests.
func StupidEmitter ¶ added in v0.4.0
func StupidEmitter() (*Emitter, *user.Provisioners)
StupidEmitter ...
func (*Emitter) Gossip ¶ added in v0.4.0
Gossip concatenates the topic, the header and the payload, and gossips it to the rest of the network.
type ExecuteTxsFunc ¶ added in v0.4.4
type ExecuteTxsFunc func(ctx context.Context, txs []transactions.ContractCall, blockHeight uint64) ([]transactions.ContractCall, []byte, error)
ExecuteTxsFunc is a callback used to retrieve a valid set of txs.
type InternalPacket ¶ added in v0.3.0
InternalPacket is a specialization of the Payload of message.Message. It is used to unify messages used by the consensus, which need to carry the header.Header for consensus specific operations.
type Phase ¶ added in v0.4.0
type Phase interface { // Initialize accepts as an // argument an interface, usually a message or the result of the state // function execution. It provides the capability to create a closure of sort. Initialize(InternalPacket) PhaseFn }
Phase is used whenever an instantiation is needed.
type PhaseFn ¶ added in v0.4.0
type PhaseFn interface { // Run the phase function. Run(context.Context, *Queue, chan message.Message, RoundUpdate, uint8) PhaseFn // String returns the description of this phase function. String() string }
PhaseFn represents the recursive consensus state function.
type Publisher ¶ added in v0.4.0
type Publisher struct {
// contains filtered or unexported fields
}
Publisher is used to direct consensus messages from the peer.MessageProcessor to the consensus components.
func NewPublisher ¶ added in v0.4.0
NewPublisher returns an initialized Publisher.
type Queue ¶ added in v0.2.0
type Queue struct {
// contains filtered or unexported fields
}
Queue is a Queue of Events grouped by rounds and steps. It is thread-safe through a sync.RWMutex. TODO: entries should become buntdb instead.
func NewQueue ¶ added in v0.2.0
func NewQueue() *Queue
NewQueue creates a new Queue. It is primarily used by Collectors to temporarily store messages not yet relevant to the collection process.
func (*Queue) Clear ¶ added in v0.2.0
Clear the queue. This method swaps the internal `entries` map, to avoid a situation where memory is continuously allocated and never freed.
func (*Queue) Flush ¶ added in v0.2.0
Flush all events stored for a specific round from the queue, and return them Messages are sorted giving priority to AggrAgreement and then to their step.
type RoundUpdate ¶ added in v0.2.0
type RoundUpdate struct { Round uint64 P user.Provisioners Seed []byte Hash []byte LastCertificate *block.Certificate }
RoundUpdate carries the data about the new Round, such as the active Provisioners, the BidList, the Seed and the Hash.
func MockRoundUpdate ¶ added in v0.2.0
func MockRoundUpdate(round uint64, p *user.Provisioners) RoundUpdate
MockRoundUpdate mocks a round update.
func (RoundUpdate) Copy ¶ added in v0.4.0
func (r RoundUpdate) Copy() payload.Safe
Copy complies with message.Safe interface. It returns a deep copy of the message safe to publish to multiple subscribers.
type TestCallback ¶ added in v0.4.0
type TestCallback func(*require.Assertions, InternalPacket, *eventbus.GossipStreamer)
TestCallback is a callback to allow for table testing based on step results.
type TestPhase ¶ added in v0.4.0
type TestPhase struct {
// contains filtered or unexported fields
}
TestPhase is the phase to inject in the step under test to allow for table testing. It treats the packet injected through the Fn method as the result to test.
func NewTestPhase ¶ added in v0.4.0
func NewTestPhase(t *testing.T, callback TestCallback, streamer *eventbus.GossipStreamer) *TestPhase
NewTestPhase returns a Phase implementation suitable for testing steps.
func (*TestPhase) Initialize ¶ added in v0.4.0
func (t *TestPhase) Initialize(sv InternalPacket) PhaseFn
Initialize is used by the step under test to provide its result.