Documentation ¶
Overview ¶
Package mirbft is a consensus library, implementing the Mir BFT consensus protocol.
This library can be used by applications which desire distributed, byzantine fault tolerant consensus on message order. Unlike many traditional consensus algorithms, Mir BFT is a multi-leader protocol, allowing throughput to scale with the number of nodes (even over WANs), where the performance of traditional consenus algorithms begin to degrade.
Index ¶
- Variables
- func StandardInitialNetworkState(nodeCount int, clientCount int) *msgs.NetworkState
- type Config
- type LogLevel
- type Logger
- type Node
- func (n *Node) ProcessAsNewNode(exitC <-chan struct{}, tickC <-chan time.Time, ...) error
- func (n *Node) RestartProcessing(exitC <-chan struct{}, tickC <-chan time.Time) error
- func (n *Node) Status(ctx context.Context) (*status.StateMachine, error)
- func (n *Node) Step(ctx context.Context, source uint64, msg *msgs.Msg) error
- type ProcessorConfig
Constants ¶
This section is empty.
Variables ¶
var ErrStopped = fmt.Errorf("stopped at caller request")
Functions ¶
func StandardInitialNetworkState ¶
func StandardInitialNetworkState(nodeCount int, clientCount int) *msgs.NetworkState
Types ¶
type Config ¶
type Config struct { // Logger provides the logging functions. Logger Logger // BatchSize determines how large a batch may grow (in number of request) // before it is cut. (Note, batches may be cut earlier, so this is a max size). BatchSize uint32 // HeartbeatTicks is the number of ticks before a heartbeat is emitted // by a leader. HeartbeatTicks uint32 // SuspectTicks is the number of ticks a bucket may not progress before // the node suspects the epoch has gone bad. SuspectTicks uint32 // NewEpochTimeoutTicks is the number of ticks a replica will wait until // it suspects the epoch leader has failed. This value must be greater // than 1, as rebroadcast ticks are computed as half this value. NewEpochTimeoutTicks uint32 // BufferSize is the total size of messages which can be held by the state // machine, pending application, for each node. This is necessary because // there may be dependencies between messages (for instance, until a checkpoint // result is computed, watermarks cannot advance). This should be set // to a minimum of a few MB. BufferSize uint32 }
type Logger ¶
type Logger interface { // Log is invoked with the log level, the log message, and key/value pairs // of any relevant log details. The keys are always strings, while the // values are unspecified. Log(level LogLevel, text string, args ...interface{}) }
Logger is minimal logging interface designed to be easily adaptable to any logging library.
var ( // ConsoleDebugLogger implements Logger and writes all log messages to stdout. ConsoleDebugLogger Logger = consoleLogger(LevelDebug) // ConsoleInfoLogger implements Logger and writes all LevelInfo and above log messages to stdout. ConsoleInfoLogger Logger = consoleLogger(LevelInfo) // ConsoleWarnLogger implements Logger and writes all LevelWarn and above log messages to stdout. ConsoleWarnLogger Logger = consoleLogger(LevelWarn) // ConsoleErrorLogger implements Logger and writes all LevelError log messages to stdout. ConsoleErrorLogger Logger = consoleLogger(LevelError) )
type Node ¶
type Node struct { ID uint64 Config *Config // Exported as a temporary hack ResultEventsC chan *statemachine.EventList ResultResultsC chan *statemachine.ActionList Clients *processor.Clients // contains filtered or unexported fields }
Node is the local instance of the MirBFT state machine through which the calling application proposes new messages, receives delegated actions, and returns action results. The methods exposed on Node are all thread safe, though typically, a single loop handles reading Actions, writing results, and writing ticks, while other go routines Propose and Step.
func NewNode ¶
func NewNode( id uint64, config *Config, processorConfig *ProcessorConfig, ) (*Node, error)
NewNode creates a new node. The processor must be started either by invoking node.Processor.StartNewNode with the initial state or by invoking node.Processor.RestartNode.
func (*Node) ProcessAsNewNode ¶
func (*Node) RestartProcessing ¶
func (*Node) Status ¶
Status returns a static snapshot in time of the internal state of the state machine. This method necessarily exposes some of the internal architecture of the system, and especially while the library is in development, the data structures may change substantially. This method returns a nil status and an error if the context ends. If the serializer go routine exits for any other reason, then a best effort is made to return the last (and final) status. This final status may be relied upon if it is non-nil. If the serializer exited at the user's request (because the done channel was closed), then ErrStopped is returned.
type ProcessorConfig ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
mircat
mircat is a package for reviewing Mir state machine recordings.
|
mircat is a package for reviewing Mir state machine recordings. |
pkg
|
|
reqstore
Package reqstore is an implementation of the RequestStore utilized by the samples.
|
Package reqstore is an implementation of the RequestStore utilized by the samples. |
simplewal
Package simplewal is a basic WAL implementation meant to be the first 'real' WAL option for mirbft.
|
Package simplewal is a basic WAL implementation meant to be the first 'real' WAL option for mirbft. |
testengine
Package testengine provides a way to write deterministic, repeatable, serializable, and analyzable tests.
|
Package testengine provides a way to write deterministic, repeatable, serializable, and analyzable tests. |