zbft

package module
v0.0.0-...-6bca171 Latest Latest
Warning

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

Go to latest
Published: May 28, 2018 License: MPL-2.0 Imports: 12 Imported by: 0

README

zbft

Byzantine fault tolerant consensus algorithm for blockchain

  • Prepared Tx's are collected by each node
  • Node proposes a new block
  • Each participant signs the block
  • Each participant persists after receiving enough signatures
  • Each participant commits after receiving enough persists
  • Each participant executes each Tx in the block

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Key pair for the node
	KeyPair *keypair.KeyPair

	// Blockchain instance
	Blockchain *blockchain.Blockchain

	// Finite state machine for the blockchain
	FSM FSM

	// Logger
	Logger *log.Logger
}

Config is the configuration used to initialize a ZBFT instance

type FSM

type FSM interface {
	// Initializes the fsm with the given read-only tx store
	Init(store TxStore)
	// Prepare prepares the tx set writing the outputs back into the tx outputs
	Prepare(txs []*bcpb.Tx) error
	// Executes applies the given transactions
	Execute(txs []*bcpb.Tx, block *bcpb.BlockHeader, leader bool) error
}

FSM implements a finite-state-machine used by zbft

type Future

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

Future represents a set of transactions that are undergoing ratification. These have not yet been applied and/or executed. It is used to signal completion of ratification and execution.

func (*Future) Executed

func (a *Future) Executed(timeout time.Duration) error

Executed until execution completes or timeout is reached.

func (*Future) Ratified

func (a *Future) Ratified(timeout time.Duration) error

Ratified block until ratification is complete or time out occurs returning the ratification error or timeout err or if any

func (*Future) Txs

func (a *Future) Txs() []*bcpb.Tx

Txs returns the transactions for the future. The return will be nil if there is an error or preparation has not completed. The returned transactions should be considered valid only after ratification has completed.

func (*Future) Wait

func (a *Future) Wait(timeout time.Duration) error

Wait blocks until both ratification and execution complete whether they succeed or fail

type TxStore

type TxStore interface {
	// Returns the output associated to the given input
	GetTXO(txi *bcpb.TxInput) (*bcpb.TxOutput, error)
}

TxStore implements a transaction store for read-only purposes

type ZBFT

type ZBFT interface {
	// Start zbft
	Start()
	// SetGenesis is used to set the genesis block.  This can only be called
	// once for each ledger
	SetGenesis(blk *bcpb.Block, txs []*bcpb.Tx) *Future
	// Submits message to consensus algo
	Step(msg zbftpb.Message)
	// SetTimeout sets the timeout for a given consensus round
	SetTimeout(d time.Duration)
	// ProposeTxs proposes Transactions to the ledger.  They are first prepared,
	// added to a block then proposes to be added to the ledger
	ProposeTxs(txs []*bcpb.Tx) *Future
	// BroadcastMessages returns a read-only channel of messages that need to be
	// broadcasted to the network
	BroadcastMessages() <-chan zbftpb.Message
}

ZBFT is the interface used by the user to interact with the consensus alogrithm to perform ops against it

func New

func New(conf *Config) ZBFT

New instantiates a new zbft instance. It takes a blockchain, finite-state-machine and a keypair as arguments

Directories

Path Synopsis
Package zbftpb is a generated protocol buffer package.
Package zbftpb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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