consensus

package
v0.6.0-preview Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2016 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Communicator

type Communicator interface {
	Broadcast(msg *pb.Message, peerType pb.PeerEndpoint_Type) error
	Unicast(msg *pb.Message, receiverHandle *pb.PeerID) error
}

Communicator is used to send messages to other validators

type Consenter

type Consenter interface {
	RecvMsg(msg *pb.Message, senderHandle *pb.PeerID) error // Called serially with incoming messages from gRPC
	ExecutionConsumer
}

Consenter is used to receive messages from the network Every consensus plugin needs to implement this interface

type ExecutionConsumer

type ExecutionConsumer interface {
	Executed(tag interface{})                                // Called whenever Execute completes
	Committed(tag interface{}, target *pb.BlockchainInfo)    // Called whenever Commit completes
	RolledBack(tag interface{})                              // Called whenever a Rollback completes
	StateUpdated(tag interface{}, target *pb.BlockchainInfo) // Called when state transfer completes, if target is nil, this indicates a failure and a new target should be supplied
}

ExecutionConsumer allows callbacks from asycnhronous execution and statetransfer

type Executor

type Executor interface {
	Start()                                                                     // Bring up the resources needed to use this interface
	Halt()                                                                      // Tear down the resources needed to use this interface
	Execute(tag interface{}, txs []*pb.Transaction)                             // Executes a set of transactions, this may be called in succession
	Commit(tag interface{}, metadata []byte)                                    // Commits whatever transactions have been executed
	Rollback(tag interface{})                                                   // Rolls back whatever transactions have been executed
	UpdateState(tag interface{}, target *pb.BlockchainInfo, peers []*pb.PeerID) // Attempts to synchronize state to a particular target, implicitly calls rollback if needed
}

Executor is intended to eventually supplant the old Executor interface The problem with invoking the calls directly above, is that they must be coordinated with state transfer, to eliminate possible races and ledger corruption

type Inquirer

type Inquirer interface {
	GetNetworkInfo() (self *pb.PeerEndpoint, network []*pb.PeerEndpoint, err error)
	GetNetworkHandles() (self *pb.PeerID, network []*pb.PeerID, err error)
}

Inquirer is used to retrieve info about the validating network

type LedgerManager

type LedgerManager interface {
	InvalidateState() // Invalidate informs the ledger that it is out of date and should reject queries
	ValidateState()   // Validate informs the ledger that it is back up to date and should resume replying to queries
}

LedgerManager is used to manipulate the state of the ledger

type LegacyExecutor

type LegacyExecutor interface {
	BeginTxBatch(id interface{}) error
	ExecTxs(id interface{}, txs []*pb.Transaction) ([]byte, error)
	CommitTxBatch(id interface{}, metadata []byte) (*pb.Block, error)
	RollbackTxBatch(id interface{}) error
	PreviewCommitTxBatch(id interface{}, metadata []byte) ([]byte, error)
}

LegacyExecutor is used to invoke transactions, potentially modifying the backing ledger

type NetworkStack

type NetworkStack interface {
	Communicator
	Inquirer
}

NetworkStack is used to retrieve network info and send messages

type ReadOnlyLedger

type ReadOnlyLedger interface {
	GetBlock(id uint64) (block *pb.Block, err error)
	GetBlockchainSize() uint64
	GetBlockchainInfo() *pb.BlockchainInfo
	GetBlockchainInfoBlob() []byte
	GetBlockHeadMetadata() ([]byte, error)
}

ReadOnlyLedger is used for interrogating the blockchain

type SecurityUtils

type SecurityUtils interface {
	Sign(msg []byte) ([]byte, error)
	Verify(peerID *pb.PeerID, signature []byte, message []byte) error
}

SecurityUtils is used to access the sign/verify methods from the crypto package

type Stack

Stack is the set of stack-facing methods available to the consensus plugin

type StatePersistor

type StatePersistor interface {
	StoreState(key string, value []byte) error
	ReadState(key string) ([]byte, error)
	ReadStateSet(prefix string) (map[string][]byte, error)
	DelState(key string)
}

StatePersistor is used to store consensus state which should survive a process crash

Directories

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

Jump to

Keyboard shortcuts

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