consensus_pbft

package
v0.0.0-...-23aeb14 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2019 License: GPL-3.0 Imports: 3 Imported by: 0

README

###Message Layer ####1. net message struct Message ####2. pbft message struct PbftMessage

seqNo has been saved in block.header in fabric

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 *message.Message, peerType pbftTypes.Peer_Type) error
	Unicast(msg *message.Message, receiverHandle *pbftTypes.PeerID) error
}

Communicator is used to send messages to other validators

type Consenter

type Consenter interface {
	RecvMsg(msg *message.Message, senderHandle *pbftTypes.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{}, state *message.StateInfo)    // Called whenever Commit completes
	RolledBack(tag interface{})                             // Called whenever a Rollback completes
	StateUpdated(tag interface{}, state *message.StateInfo) // 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 []*message.Task)                                      // 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 *message.StateInfo, peers []*pbftTypes.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 {
	GetNetworkNodes() (self pbftTypes.Peer, network []pbftTypes.Peer, err error)
	GetNetworkNodeIDs() (self *pbftTypes.PeerID, network []*pbftTypes.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 NetworkStack

type NetworkStack interface {
	Communicator
	Inquirer
}

NetworkStack is used to retrieve network info and send messages

type ReadOnlyLedger

type ReadOnlyLedger interface {
	GetState(height uint64) (state *message.StateInfo, err error)
	//	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 pbftTypes.ReplicaID, signature []byte, message []byte) error
}

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

type Stack

type Stack interface {
	NetworkStack                    // 网络消息发送和接收接口
	SecurityUtils                   // Sign和Verify接口
	Executor                        // 事件消息处理接口
	consensusInterface.NodeExecutor // 交易处理接口
	LedgerManager                   // 控制ledger的状态
	ReadOnlyLedger                  // 操作blockchain
	StatePersistor                  // 操作共识状态
}

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

Jump to

Keyboard shortcuts

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