peer

package
v0.0.0-...-1d5e6b2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheConfiguration

func CacheConfiguration() (err error)

CacheConfiguration computes and caches commonly-used constants and computed constants as package variables. Routines which were previously global have been embedded here to preserve the original abstraction.

func GetLocalAddress

func GetLocalAddress() (string, error)

GetLocalAddress returns the peer.address property

func GetLocalIP

func GetLocalIP() string

GetLocalIP returns the non loopback local IP of the host

func GetPeerEndpoint

func GetPeerEndpoint() (*pb.PeerEndpoint, error)

func NewPeerClientConnection

func NewPeerClientConnection() (*grpc.ClientConn, error)

NewPeerClientConnection Returns a new grpc.ClientConn to the configured local PEER.

func NewPeerClientConnectionWithAddress

func NewPeerClientConnectionWithAddress(peerAddress string) (*grpc.ClientConn, error)

NewPeerClientConnectionWithAddress Returns a new grpc.ClientConn to the configured local PEER.

func SecurityEnabled

func SecurityEnabled() bool

func SyncBlocksChannelSize

func SyncBlocksChannelSize() int

SyncBlocksChannelSize returns the peer.sync.blocks.channelSize property

func SyncStateDeltasChannelSize

func SyncStateDeltasChannelSize() int

SyncStateDeltasChannelSize returns the peer.sync.state.deltas.channelSize property

func SyncStateSnapshotChannelSize

func SyncStateSnapshotChannelSize() int

SyncStateSnapshotChannelSize returns the peer.sync.state.snapshot.channelSize property

func ValidatorEnabled

func ValidatorEnabled() bool

ValidatorEnabled returns the peer.validator.enabled property

Types

type BlockChainAccessor

type BlockChainAccessor interface {
	GetBlockByNumber(blockNumber uint64) (*pb.Block, error)
	GetBlockchainSize() uint64
	GetCurrentStateHash() (stateHash []byte, err error)
}

BlockChainAccessor interface for retreiving blocks by block number

type BlockChainModifier

type BlockChainModifier interface {
	ApplyStateDelta(id interface{}, delta *statemgmt.StateDelta) error
	RollbackStateDelta(id interface{}) error
	CommitStateDelta(id interface{}) error
	EmptyState() error
	PutBlock(blockNumber uint64, block *pb.Block) error
}

BlockChainModifier interface for applying changes to the block chain

type BlockChainUtil

type BlockChainUtil interface {
	HashBlock(block *pb.Block) ([]byte, error)
	VerifyBlockchain(start, finish uint64) (uint64, error)
}

BlockChainUtil interface for interrogating the block chain

type BlocksRetriever

type BlocksRetriever interface {
	RequestBlocks(*pb.SyncBlockRange) (<-chan *pb.SyncBlocks, error)
}

BlocksRetriever interface for retrieving blocks .

type ChatStream

type ChatStream interface {
	Send(*pb.Message) error
	Recv() (*pb.Message, error)
}

ChatStream interface supported by stream between Peers

type DuplicateHandlerError

type DuplicateHandlerError struct {
	To pb.PeerEndpoint
}

DuplicateHandlerError returned if attempt to register same chaincodeID while a stream already exists.

func (*DuplicateHandlerError) Error

func (d *DuplicateHandlerError) Error() string

type Engine

type Engine interface {
	TransactionProccesor
	// GetHandlerFactory return a handler for an accepted Chat stream
	GetHandlerFactory() HandlerFactory
}

Engine Responsible for managing Peer network communications (Handlers) and processing of Transactions

type EngineFactory

type EngineFactory func(MessageHandlerCoordinator) (Engine, error)

EngineFactory for creating new engines

type Handler

type Handler struct {
	ToPeerEndpoint *pb.PeerEndpoint
	Coordinator    MessageHandlerCoordinator
	ChatStream     ChatStream

	FSM *fsm.FSM
	// contains filtered or unexported fields
}

Handler peer handler implementation.

func (*Handler) HandleMessage

func (d *Handler) HandleMessage(msg *pb.Message) error

HandleMessage handles the Openchain messages for the Peer.

func (*Handler) RequestBlocks

func (d *Handler) RequestBlocks(syncBlockRange *pb.SyncBlockRange) (<-chan *pb.SyncBlocks, error)

RequestBlocks get the blocks from the other PeerEndpoint based upon supplied SyncBlockRange, will provide them through the returned channel. this will also stop writing any received blocks to channels created from Prior calls to RequestBlocks(..)

func (*Handler) RequestStateDeltas

func (d *Handler) RequestStateDeltas(syncBlockRange *pb.SyncBlockRange) (<-chan *pb.SyncStateDeltas, error)

RequestStateDeltas get the state snapshot deltas from the other PeerEndpoint, will provide them through the returned channel. this will also stop writing any received syncStateSnapshot(s) to channels created from Prior calls to GetStateSnapshot()

func (*Handler) RequestStateSnapshot

func (d *Handler) RequestStateSnapshot() (<-chan *pb.SyncStateSnapshot, error)

RequestStateSnapshot request the state snapshot deltas from the other PeerEndpoint, will provide them through the returned channel. this will also stop writing any received syncStateSnapshot(s) to channels created from Prior calls to RequestStateSnapshot()

func (*Handler) SendMessage

func (d *Handler) SendMessage(msg *pb.Message) error

SendMessage sends a message to the remote PEER through the stream

func (*Handler) Stop

func (d *Handler) Stop() error

Stop stops this handler, which will trigger the Deregister from the MessageHandlerCoordinator.

func (*Handler) To

func (d *Handler) To() (pb.PeerEndpoint, error)

To return the PeerEndpoint this Handler is connected to.

type HandlerFactory

HandlerFactory for creating new MessageHandlers

type MessageHandler

type MessageHandler interface {
	RemoteLedger
	HandleMessage(msg *pb.Message) error
	SendMessage(msg *pb.Message) error
	To() (pb.PeerEndpoint, error)
	Stop() error
}

MessageHandler standard interface for handling Openchain messages.

func NewPeerHandler

func NewPeerHandler(coord MessageHandlerCoordinator, stream ChatStream, initiatedStream bool, nextHandler MessageHandler) (MessageHandler, error)

NewPeerHandler returns a new Peer handler Is instance of HandlerFactory

type MessageHandlerCoordinator

type MessageHandlerCoordinator interface {
	Peer
	SecurityAccessor
	BlockChainAccessor
	BlockChainModifier
	BlockChainUtil
	StateAccessor
	TransactionAccessor
	RegisterHandler(messageHandler MessageHandler) error
	DeregisterHandler(messageHandler MessageHandler) error
	Broadcast(*pb.Message, pb.PeerEndpoint_Type) []error
	Unicast(*pb.Message, *pb.PeerID) error
	GetPeers() (*pb.PeersMessage, error)
	GetRemoteLedger(receiver *pb.PeerID) (RemoteLedger, error)
	PeersDiscovered(*pb.PeersMessage) error
	ExecuteTransaction(transaction *pb.Transaction) *pb.Response
}

MessageHandlerCoordinator responsible for coordinating between the registered MessageHandler's

type Peer

type Peer interface {
	GetPeerEndpoint() (*pb.PeerEndpoint, error)
	NewOpenchainDiscoveryHello() (*pb.Message, error)
}

Peer provides interface for a peer

type PeerImpl

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

PeerImpl implementation of the Peer service

func NewPeerWithEngine

func NewPeerWithEngine(secHelperFunc func() crypto.Peer, engFactory EngineFactory, discInstance discovery.Discovery) (peer *PeerImpl, err error)

NewPeerWithEngine returns a Peer which uses the supplied handler factory function for creating new handlers on new Chat service invocations.

func NewPeerWithHandler

func NewPeerWithHandler(secHelperFunc func() crypto.Peer, handlerFact HandlerFactory, discInstance discovery.Discovery) (*PeerImpl, error)

NewPeerWithHandler returns a Peer which uses the supplied handler factory function for creating new handlers on new Chat service invocations.

func (*PeerImpl) ApplyStateDelta

func (p *PeerImpl) 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 (*PeerImpl) Broadcast

func (p *PeerImpl) Broadcast(msg *pb.Message, typ pb.PeerEndpoint_Type) []error

Broadcast broadcast a message to each of the currently registered PeerEndpoints of given type Broadcast will broadcast to all registered PeerEndpoints if the type is PeerEndpoint_UNDEFINED

func (*PeerImpl) Chat

func (p *PeerImpl) Chat(stream pb.Peer_ChatServer) error

Chat implementation of the the Chat bidi streaming RPC function

func (*PeerImpl) CommitStateDelta

func (p *PeerImpl) CommitStateDelta(id interface{}) error

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

func (*PeerImpl) DeregisterHandler

func (p *PeerImpl) DeregisterHandler(messageHandler MessageHandler) error

DeregisterHandler deregisters an already registered MessageHandler for this coordinator

func (*PeerImpl) EmptyState

func (p *PeerImpl) EmptyState() error

EmptyState completely empties the state and prepares it to restore a snapshot

func (*PeerImpl) ExecuteTransaction

func (p *PeerImpl) ExecuteTransaction(transaction *pb.Transaction) (response *pb.Response)

ExecuteTransaction executes transactions decides to do execute in dev or prod mode

func (*PeerImpl) GetBlockByNumber

func (p *PeerImpl) GetBlockByNumber(blockNumber uint64) (*pb.Block, error)

GetBlockByNumber return a block by block number

func (*PeerImpl) GetBlockchainSize

func (p *PeerImpl) GetBlockchainSize() uint64

GetBlockchainSize returns the height/length of the blockchain

func (*PeerImpl) GetCurrentStateHash

func (p *PeerImpl) GetCurrentStateHash() (stateHash []byte, err error)

GetCurrentStateHash returns the current non-committed hash of the in memory state

func (*PeerImpl) GetPeerEndpoint

func (p *PeerImpl) GetPeerEndpoint() (*pb.PeerEndpoint, error)

GetPeerEndpoint returns the endpoint for this peer

func (*PeerImpl) GetPeers

func (p *PeerImpl) GetPeers() (*pb.PeersMessage, error)

GetPeers returns the currently registered PeerEndpoints

func (*PeerImpl) GetRemoteLedger

func (p *PeerImpl) GetRemoteLedger(receiverHandle *pb.PeerID) (RemoteLedger, error)

GetRemoteLedger returns the RemoteLedger interface for the remote Peer Endpoint

func (*PeerImpl) GetSecHelper

func (p *PeerImpl) GetSecHelper() crypto.Peer

GetSecHelper returns the crypto.Peer

func (*PeerImpl) GetStateDelta

func (p *PeerImpl) GetStateDelta(blockNumber uint64) (*statemgmt.StateDelta, error)

GetStateDelta return the state delta for the requested block number

func (*PeerImpl) GetStateSnapshot

func (p *PeerImpl) GetStateSnapshot() (*state.StateSnapshot, error)

GetStateSnapshot return the state snapshot

func (*PeerImpl) GetTransactionResultByUUID

func (p *PeerImpl) GetTransactionResultByUUID(txUuid string) (*pb.TransactionResult, error)

GetTransactionResultByUUID Return the TransactionResult for the specified transaction ID.

func (*PeerImpl) HashBlock

func (p *PeerImpl) HashBlock(block *pb.Block) ([]byte, error)

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

func (*PeerImpl) NewOpenchainDiscoveryHello

func (p *PeerImpl) NewOpenchainDiscoveryHello() (*pb.Message, error)

NewOpenchainDiscoveryHello constructs a new HelloMessage for sending

func (*PeerImpl) PeersDiscovered

func (p *PeerImpl) PeersDiscovered(peersMessage *pb.PeersMessage) error

PeersDiscovered used by MessageHandlers for notifying this coordinator of discovered PeerEndoints. May include this Peer's PeerEndpoint.

func (*PeerImpl) ProcessTransaction

func (p *PeerImpl) ProcessTransaction(ctx context.Context, tx *pb.Transaction) (response *pb.Response, err error)

ProcessTransaction implementation of the ProcessTransaction RPC function

func (*PeerImpl) PutBlock

func (p *PeerImpl) 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 (*PeerImpl) RegisterHandler

func (p *PeerImpl) RegisterHandler(messageHandler MessageHandler) error

RegisterHandler register a MessageHandler with this coordinator

func (*PeerImpl) RollbackStateDelta

func (p *PeerImpl) RollbackStateDelta(id interface{}) error

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

func (*PeerImpl) SendTransactionsToPeer

func (p *PeerImpl) SendTransactionsToPeer(peerAddress string, transaction *pb.Transaction) (response *pb.Response)

SendTransactionsToPeer forwards transactions to the specified peer address.

func (*PeerImpl) Unicast

func (p *PeerImpl) Unicast(msg *pb.Message, receiverHandle *pb.PeerID) error

Unicast sends a message to a specific peer.

func (*PeerImpl) VerifyBlockchain

func (p *PeerImpl) 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

type RemoteLedger

type RemoteLedger interface {
	BlocksRetriever
	StateRetriever
}

RemoteLedger interface for retrieving remote ledger data.

type SecurityAccessor

type SecurityAccessor interface {
	GetSecHelper() crypto.Peer
}

SecurityAccessor interface enables a Peer to hand out the crypto object for Peer

type StateAccessor

type StateAccessor interface {
	GetStateSnapshot() (*state.StateSnapshot, error)
	GetStateDelta(blockNumber uint64) (*statemgmt.StateDelta, error)
}

StateAccessor interface for retreiving blocks by block number

type StateRetriever

type StateRetriever interface {
	RequestStateSnapshot() (<-chan *pb.SyncStateSnapshot, error)
	RequestStateDeltas(syncBlockRange *pb.SyncBlockRange) (<-chan *pb.SyncStateDeltas, error)
}

StateRetriever interface for retrieving state deltas, etc.

type TransactionAccessor

type TransactionAccessor interface {
	GetTransactionResultByUUID(txUuid string) (*pb.TransactionResult, error)
}

TransactionAccessor interface for retrieving transaction information

type TransactionProccesor

type TransactionProccesor interface {
	ProcessTransactionMsg(*pb.Message, *pb.Transaction) *pb.Response
}

TransactionProccesor responsible for processing of Transactions

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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