Version: v0.1.0 Latest Latest

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

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




This section is empty.


This section is empty.


func GetLocalAddress

func GetLocalAddress() (peerAddress string, err error)

GetLocalAddress returns the address:port the local peer is operating on. Affected by env:peer.addressAutoDetect

func GetLocalIP

func GetLocalIP() string

GetLocalIP returns the non loopback local IP of the host

func GetPeerEndpoint

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

GetPeerEndpoint returns the PeerEndpoint for this Peer instance. Affected by env:peer.addressAutoDetect

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.


type BlockChainAccessor

type BlockChainAccessor interface {
	GetBlockByNumber(blockNumber uint64) (*pb.Block, error)

BlockChainAccessor interface for retreiving blocks by block number

type BlocksRetriever

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

BlocksRetriever interface for retrieving blocks .

type ChatStream

type ChatStream interface {
	Send(*pb.OpenchainMessage) error
	Recv() (*pb.OpenchainMessage, 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 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.OpenchainMessage) 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.OpenchainMessage) 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 MessageHandler

type MessageHandler interface {
	HandleMessage(msg *pb.OpenchainMessage) error
	SendMessage(msg *pb.OpenchainMessage) 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 {
	RegisterHandler(messageHandler MessageHandler) error
	DeregisterHandler(messageHandler MessageHandler) error
	Broadcast(*pb.OpenchainMessage, pb.PeerEndpoint_Type) []error
	Unicast(*pb.OpenchainMessage, *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.OpenchainMessage, error)

Peer provides interface for a peer

type PeerImpl

type PeerImpl struct {
	// contains filtered or unexported fields

PeerImpl implementation of the Peer service

func NewPeerWithHandler

func NewPeerWithHandler(handlerFact HandlerFactory) (*PeerImpl, error)

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

func (*PeerImpl) Broadcast

func (p *PeerImpl) Broadcast(msg *pb.OpenchainMessage, 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) DeregisterHandler

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

DeregisterHandler deregisters an already registered MessageHandler for this coordinator

func (*PeerImpl) ExecuteTransaction

func (p *PeerImpl) ExecuteTransaction(transaction *pb.Transaction) *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) 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) NewOpenchainDiscoveryHello

func (p *PeerImpl) NewOpenchainDiscoveryHello() (*pb.OpenchainMessage, 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) RegisterHandler

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

RegisterHandler register a MessageHandler with this coordinator

func (*PeerImpl) SendTransactionsToPeer

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

SendTransactionsToPeer current temporary mechanism of forwarding transactions to the configured Validator.

func (*PeerImpl) Unicast

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

Unicast sends a message to a specific peer.

type RemoteLedger

type RemoteLedger interface {

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.

Jump to

Keyboard shortcuts

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