helper

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

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

func NewHelper

NewHelper constructs the consensus helper object

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

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.OpenchainMessage, peerType pb.PeerEndpoint_Type) error

Broadcast sends a message to all validating peers

func (*Helper) CommitStateDelta

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

CommitStateDelta makes the result of ApplyStateDelta permanent and releases the resources necessary to rollback the delta

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) EmptyState

func (h *Helper) EmptyState() error

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) GetBlock

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

GetBlock returns a block from the chain

func (*Helper) GetBlockchainSize

func (h *Helper) GetBlockchainSize() (uint64, error)

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) 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

func (h *Helper) GetRemoteStateSnapshot(replicaID *pb.PeerID) (<-chan *pb.SyncStateSnapshot, error)

GetRemoteStateSnapshot will return a channel to stream a state snapshot from the desired replicaID

func (*Helper) HashBlock

func (h *Helper) HashBlock(block *pb.Block) ([]byte, error)

HashBlock returns the hash of the included block, useful for mocking

func (*Helper) PreviewCommitTxBatch

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

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

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

PutBlock inserts a raw block into the blockchain at the specified index, nearly no error checking is performed

func (*Helper) RollbackStateDelta

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

RollbackStateDelta undoes the results of ApplyStateDelta to revert the current state back to the state before ApplyStateDelta was invoked

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) Sign

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

Sign a message with this validator's signing key

func (*Helper) Unicast

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

Unicast sends a message to a specified receiver

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

func (*Helper) VerifyBlockchain

func (h *Helper) VerifyBlockchain(start, finish uint64) (uint64, error)

VerifyBlockchain checks the integrity of the blockchain between indices start and finish, returning the first block who's PreviousBlockHash field does not match the hash of the previous block

Jump to

Keyboard shortcuts

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