candidate

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate added in v0.3.0

func Validate(m message.Message) error

Validate complies with the republisher.Validator interface. It internally invokes ValidateCandidate

func ValidateCandidate added in v0.3.0

func ValidateCandidate(cm message.Candidate) error

ValidateCandidate makes sure the hash and root are correct, to avoid malicious nodes from // overwriting the candidate block for a specific hash

Types

type Broker

type Broker struct {
	// contains filtered or unexported fields
}

Broker is the entry point for the candidate component. It manages an in-memory store of `Candidate` messages, and allows for the fetching of these messages through the `RPCBus`. It listens for incoming `Candidate` messages and puts them on the store. In case an internal component requests an absent `Candidate` message, the Broker can make a `GetCandidate` request to the rest of the network, and will attempt to provide the requesting component with it's needed `Candidate`.

func NewBroker

func NewBroker(broker eventbus.Broker, rpcBus *rpcbus.RPCBus) *Broker

NewBroker returns an initialized Broker struct. It will still need to be started by calling `Listen`.

func (*Broker) AddValidHash added in v0.3.0

func (b *Broker) AddValidHash(m message.Message) error

AddValidHash to the local cache for a score. Broker.validHashes uses a map to implement a HashSet

func (Broker) Clear

func (c Broker) Clear(round uint64) int

Clear removes all candidate messages from or before a given round. Returns the amount of messages deleted.

func (*Broker) Listen

func (b *Broker) Listen()

Listen for incoming `Candidate` messages, and internal requests. Should be run in a goroutine.

func (*Broker) Validate added in v0.3.0

func (b *Broker) Validate(m message.Message) error

Validate that the candidate block carried by a message has not been already republished. This function complies to the republisher.Validator interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL