helper

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: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultConsensusQueueSize value of 1000
	DefaultConsensusQueueSize int = 1000
)

Variables

This section is empty.

Functions

func GetEngine

func GetEngine(coord peer.MessageHandlerCoordinator) (peer.Engine, error)

GetEngine returns initialized peer.Engine

func NewConsensusHandler

func NewConsensusHandler(coord peer.MessageHandlerCoordinator,
	stream peer.ChatStream, initiatedStream bool) (peer.MessageHandler, error)

NewConsensusHandler constructs a new MessageHandler for the plugin. Is instance of peer.HandlerFactory

Types

type ConsensusHandler

type ConsensusHandler struct {
	peer.MessageHandler
	// contains filtered or unexported fields
}

ConsensusHandler handles consensus messages. It also implements the Stack.

func (*ConsensusHandler) HandleMessage

func (handler *ConsensusHandler) HandleMessage(msg *pb.Message) error

HandleMessage handles the incoming Fabric messages for the Peer

type EngineImpl

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

EngineImpl implements a struct to hold consensus.Consenter, PeerEndpoint and MessageFan

func (*EngineImpl) GetHandlerFactory

func (eng *EngineImpl) GetHandlerFactory() peer.HandlerFactory

GetHandlerFactory returns new NewConsensusHandler

func (*EngineImpl) ProcessTransactionMsg

func (eng *EngineImpl) ProcessTransactionMsg(msg *pb.Message, tx *pb.Transaction) (response *pb.Response)

ProcessTransactionMsg processes a Message in context of a Transaction

type Helper

type Helper struct {
	persist.Helper
	// contains filtered or unexported fields
}

Helper contains the reference to the peer's MessageHandlerCoordinator

func NewHelper

func NewHelper(mhc peer.MessageHandlerCoordinator) *Helper

NewHelper constructs the consensus helper object

func (*Helper) BeginTxBatch

func (h *Helper) BeginTxBatch(id interface{}) error

BeginTxBatch gets invoked when the next round of transaction-batch execution begins

func (*Helper) Broadcast

func (h *Helper) Broadcast(msg *pb.Message, peerType pb.PeerEndpoint_Type) error

Broadcast sends a message to all validating peers

func (*Helper) Commit

func (h *Helper) Commit(tag interface{}, metadata []byte)

Commit will commit whatever transactions have been executed

func (*Helper) CommitTxBatch

func (h *Helper) CommitTxBatch(id interface{}, metadata []byte) (*pb.Block, error)

CommitTxBatch gets invoked when the current transaction-batch needs to be committed. This function returns successfully iff the transactions details and state changes (that may have happened during execution of this transaction-batch) have been committed to permanent storage.

func (*Helper) Committed

func (h *Helper) Committed(tag interface{}, target *pb.BlockchainInfo)

Committed is called whenever Commit completes

func (*Helper) ExecTxs

func (h *Helper) ExecTxs(id interface{}, txs []*pb.Transaction) ([]byte, error)

ExecTxs executes all the transactions listed in the txs array one-by-one. If all the executions are successful, it returns the candidate global state hash, and nil error array.

func (*Helper) Execute

func (h *Helper) Execute(tag interface{}, txs []*pb.Transaction)

Execute will execute a set of transactions, this may be called in succession

func (*Helper) Executed

func (h *Helper) Executed(tag interface{})

Executed is called whenever Execute completes

func (*Helper) GetBlock

func (h *Helper) GetBlock(blockNumber uint64) (block *pb.Block, err error)

GetBlock returns a block from the chain

func (*Helper) GetBlockHeadMetadata

func (h *Helper) GetBlockHeadMetadata() ([]byte, error)

GetBlockHeadMetadata returns metadata from block at the head of the blockchain

func (*Helper) GetBlockchainInfo

func (h *Helper) GetBlockchainInfo() *pb.BlockchainInfo

GetBlockchainInfo gets the ledger's BlockchainInfo

func (*Helper) GetBlockchainInfoBlob

func (h *Helper) GetBlockchainInfoBlob() []byte

GetBlockchainInfoBlob marshals a ledger's BlockchainInfo into a protobuf

func (*Helper) GetBlockchainSize

func (h *Helper) GetBlockchainSize() uint64

GetBlockchainSize returns the current size of the blockchain

func (*Helper) GetCurrentStateHash

func (h *Helper) GetCurrentStateHash() (stateHash []byte, err error)

GetCurrentStateHash returns the current/temporary state hash

func (*Helper) GetNetworkHandles

func (h *Helper) GetNetworkHandles() (self *pb.PeerID, network []*pb.PeerID, err error)

GetNetworkHandles returns the PeerIDs of the current validator and the entire validating network

func (*Helper) GetNetworkInfo

func (h *Helper) GetNetworkInfo() (self *pb.PeerEndpoint, network []*pb.PeerEndpoint, err error)

GetNetworkInfo returns the PeerEndpoints of the current validator and the entire validating network

func (*Helper) Halt

func (h *Helper) Halt()

Halt is a byproduct of the consensus API needing some cleaning, for now it's a no-op

func (*Helper) InvalidateState

func (h *Helper) InvalidateState()

InvalidateState is invoked to tell us that consensus realizes the ledger is out of sync

func (*Helper) PreviewCommitTxBatch

func (h *Helper) PreviewCommitTxBatch(id interface{}, metadata []byte) ([]byte, error)

PreviewCommitTxBatch retrieves a preview of the block info blob (as returned by GetBlockchainInfoBlob) that would describe the blockchain if CommitTxBatch were invoked. The blockinfo will change if additional ExecTXs calls are invoked.

func (*Helper) Rollback

func (h *Helper) Rollback(tag interface{})

Rollback will roll back whatever transactions have been executed

func (*Helper) RollbackTxBatch

func (h *Helper) RollbackTxBatch(id interface{}) error

RollbackTxBatch discards all the state changes that may have taken place during the execution of current transaction-batch

func (*Helper) RolledBack

func (h *Helper) RolledBack(tag interface{})

RolledBack is called whenever a Rollback completes

func (*Helper) Sign

func (h *Helper) Sign(msg []byte) ([]byte, error)

Sign a message with this validator's signing key

func (*Helper) Start

func (h *Helper) Start()

Start his is a byproduct of the consensus API needing some cleaning, for now it's a no-op

func (*Helper) StateUpdated

func (h *Helper) StateUpdated(tag interface{}, target *pb.BlockchainInfo)

StateUpdated is called when state transfer completes, if target is nil, this indicates a failure and a new target should be supplied

func (*Helper) Unicast

func (h *Helper) Unicast(msg *pb.Message, receiverHandle *pb.PeerID) error

Unicast sends a message to a specified receiver

func (*Helper) UpdateState

func (h *Helper) UpdateState(tag interface{}, target *pb.BlockchainInfo, peers []*pb.PeerID)

UpdateState attempts to synchronize state to a particular target, implicitly calls rollback if needed

func (*Helper) ValidateState

func (h *Helper) ValidateState()

ValidateState is invoked to tell us that consensus has the ledger back in sync

func (*Helper) Verify

func (h *Helper) Verify(replicaID *pb.PeerID, signature []byte, message []byte) error

Verify that the given signature is valid under the given replicaID's verification key If replicaID is nil, use this validator's verification key If the signature is valid, the function should return nil

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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