Documentation ¶
Index ¶
- func NewConsensusHandler(coord peer.MessageHandlerCoordinator, stream peer.ChatStream, ...) (peer.MessageHandler, error)
- func NewHelper(mhc peer.MessageHandlerCoordinator) consensus.Stack
- type ConsensusHandler
- func (handler *ConsensusHandler) HandleMessage(msg *pb.OpenchainMessage) error
- func (handler *ConsensusHandler) RequestBlocks(syncBlockRange *pb.SyncBlockRange) (<-chan *pb.SyncBlocks, error)
- func (handler *ConsensusHandler) RequestStateDeltas(syncBlockRange *pb.SyncBlockRange) (<-chan *pb.SyncStateDeltas, error)
- func (handler *ConsensusHandler) RequestStateSnapshot() (<-chan *pb.SyncStateSnapshot, error)
- func (handler *ConsensusHandler) SendMessage(msg *pb.OpenchainMessage) error
- func (handler *ConsensusHandler) Stop() error
- func (handler *ConsensusHandler) To() (pb.PeerEndpoint, error)
- type Helper
- func (h *Helper) ApplyStateDelta(id interface{}, delta *statemgmt.StateDelta) error
- func (h *Helper) BeginTxBatch(id interface{}) error
- func (h *Helper) Broadcast(msg *pb.OpenchainMessage, peerType pb.PeerEndpoint_Type) error
- func (h *Helper) CommitStateDelta(id interface{}) error
- func (h *Helper) CommitTxBatch(id interface{}, metadata []byte) (*pb.Block, error)
- func (h *Helper) EmptyState() error
- func (h *Helper) ExecTxs(id interface{}, txs []*pb.Transaction) ([]byte, error)
- func (h *Helper) GetBlock(blockNumber uint64) (block *pb.Block, err error)
- func (h *Helper) GetBlockchainSize() (uint64, error)
- func (h *Helper) GetCurrentStateHash() (stateHash []byte, err error)
- func (h *Helper) GetNetworkHandles() (self *pb.PeerID, network []*pb.PeerID, err error)
- func (h *Helper) GetNetworkInfo() (self *pb.PeerEndpoint, network []*pb.PeerEndpoint, err error)
- func (h *Helper) GetRemoteBlocks(replicaID *pb.PeerID, start, finish uint64) (<-chan *pb.SyncBlocks, error)
- func (h *Helper) GetRemoteStateDeltas(replicaID *pb.PeerID, start, finish uint64) (<-chan *pb.SyncStateDeltas, error)
- func (h *Helper) GetRemoteStateSnapshot(replicaID *pb.PeerID) (<-chan *pb.SyncStateSnapshot, error)
- func (h *Helper) HashBlock(block *pb.Block) ([]byte, error)
- func (h *Helper) PreviewCommitTxBatch(id interface{}, metadata []byte) (*pb.Block, error)
- func (h *Helper) PutBlock(blockNumber uint64, block *pb.Block) error
- func (h *Helper) RollbackStateDelta(id interface{}) error
- func (h *Helper) RollbackTxBatch(id interface{}) error
- func (h *Helper) Sign(msg []byte) ([]byte, error)
- func (h *Helper) Unicast(msg *pb.OpenchainMessage, receiverHandle *pb.PeerID) error
- func (h *Helper) Verify(replicaID *pb.PeerID, signature []byte, message []byte) error
- func (h *Helper) VerifyBlockchain(start, finish uint64) (uint64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewConsensusHandler ¶
func NewConsensusHandler(coord peer.MessageHandlerCoordinator, stream peer.ChatStream, initiatedStream bool, next peer.MessageHandler) (peer.MessageHandler, error)
NewConsensusHandler constructs a new MessageHandler for the plugin. Is instance of peer.HandlerFactory
Types ¶
type ConsensusHandler ¶
type ConsensusHandler struct {
// contains filtered or unexported fields
}
ConsensusHandler handles consensus messages. It also implements the Stack.
func (*ConsensusHandler) HandleMessage ¶
func (handler *ConsensusHandler) HandleMessage(msg *pb.OpenchainMessage) error
HandleMessage handles the incoming Openchain messages for the Peer
func (*ConsensusHandler) RequestBlocks ¶
func (handler *ConsensusHandler) RequestBlocks(syncBlockRange *pb.SyncBlockRange) (<-chan *pb.SyncBlocks, error)
RequestBlocks returns the current sync block
func (*ConsensusHandler) RequestStateDeltas ¶
func (handler *ConsensusHandler) RequestStateDeltas(syncBlockRange *pb.SyncBlockRange) (<-chan *pb.SyncStateDeltas, error)
RequestStateDeltas returns state deltas for a block range
func (*ConsensusHandler) RequestStateSnapshot ¶
func (handler *ConsensusHandler) RequestStateSnapshot() (<-chan *pb.SyncStateSnapshot, error)
RequestStateSnapshot returns the current state
func (*ConsensusHandler) SendMessage ¶
func (handler *ConsensusHandler) SendMessage(msg *pb.OpenchainMessage) error
SendMessage sends a message to the remote Peer through the stream
func (*ConsensusHandler) Stop ¶
func (handler *ConsensusHandler) Stop() error
Stop stops this MessageHandler, which then delegates to the contained PeerHandler to stop (and thus deregister this Peer)
func (*ConsensusHandler) To ¶
func (handler *ConsensusHandler) To() (pb.PeerEndpoint, error)
To returns the PeerEndpoint this Handler is connected to by delegating to the contained PeerHandler
type Helper ¶
type Helper struct {
// contains filtered or unexported fields
}
Helper contains the reference to the peer's MessageHandlerCoordinator
func (*Helper) ApplyStateDelta ¶
func (h *Helper) ApplyStateDelta(id interface{}, delta *statemgmt.StateDelta) error
ApplyStateDelta applies a state delta to the current state The result of this function can be retrieved using GetCurrentStateDelta To commit the result, call CommitStateDelta, or to roll it back call RollbackStateDelta
func (*Helper) BeginTxBatch ¶
BeginTxBatch gets invoked when the next round of transaction-batch execution begins
func (*Helper) Broadcast ¶
func (h *Helper) Broadcast(msg *pb.OpenchainMessage, peerType pb.PeerEndpoint_Type) error
Broadcast sends a message to all validating peers
func (*Helper) CommitStateDelta ¶
CommitStateDelta makes the result of ApplyStateDelta permanent and releases the resources necessary to rollback the delta
func (*Helper) CommitTxBatch ¶
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) EmptyState ¶
EmptyState completely empties the state and prepares it to restore a snapshot
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) GetBlockchainSize ¶
GetBlockchainSize returns the current size of the blockchain
func (*Helper) GetCurrentStateHash ¶
GetCurrentStateHash returns the current/temporary state hash
func (*Helper) GetNetworkHandles ¶
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) GetRemoteBlocks ¶
func (h *Helper) GetRemoteBlocks(replicaID *pb.PeerID, start, finish uint64) (<-chan *pb.SyncBlocks, error)
GetRemoteBlocks will return a channel to stream blocks from the desired replicaID
func (*Helper) GetRemoteStateDeltas ¶
func (h *Helper) GetRemoteStateDeltas(replicaID *pb.PeerID, start, finish uint64) (<-chan *pb.SyncStateDeltas, error)
GetRemoteStateDeltas will return a channel to stream a state snapshot deltas from the desired replicaID
func (*Helper) GetRemoteStateSnapshot ¶
GetRemoteStateSnapshot will return a channel to stream a state snapshot from the desired replicaID
func (*Helper) PreviewCommitTxBatch ¶
PreviewCommitTxBatch retrieves a preview copy of the block that would be inserted into the ledger if CommitTxBatch were invoked. As a preview copy, it only guarantees that the hashable portions of the block will match the committed block. Consequently, this preview block should only be used for hash computations and never distributed, passed into PutBlock, etc.. The guarantee of hashable equality will be violated if additional ExecTXs calls are invoked.
func (*Helper) PutBlock ¶
PutBlock inserts a raw block into the blockchain at the specified index, nearly no error checking is performed
func (*Helper) RollbackStateDelta ¶
RollbackStateDelta undoes the results of ApplyStateDelta to revert the current state back to the state before ApplyStateDelta was invoked
func (*Helper) RollbackTxBatch ¶
RollbackTxBatch discards all the state changes that may have taken place during the execution of current transaction-batch