Documentation ¶
Index ¶
- func GetLocalAddress() (peerAddress string, err error)
- func GetLocalIP() string
- func GetPeerEndpoint() (*pb.PeerEndpoint, error)
- func NewPeerClientConnection() (*grpc.ClientConn, error)
- func NewPeerClientConnectionWithAddress(peerAddress string) (*grpc.ClientConn, error)
- type BlockChainAccessor
- type BlocksRetriever
- type ChatStream
- type DuplicateHandlerError
- type Handler
- func (d *Handler) HandleMessage(msg *pb.OpenchainMessage) error
- func (d *Handler) RequestBlocks(syncBlockRange *pb.SyncBlockRange) (<-chan *pb.SyncBlocks, error)
- func (d *Handler) RequestStateDeltas(syncBlockRange *pb.SyncBlockRange) (<-chan *pb.SyncStateDeltas, error)
- func (d *Handler) RequestStateSnapshot() (<-chan *pb.SyncStateSnapshot, error)
- func (d *Handler) SendMessage(msg *pb.OpenchainMessage) error
- func (d *Handler) Stop() error
- func (d *Handler) To() (pb.PeerEndpoint, error)
- type HandlerFactory
- type MessageHandler
- type MessageHandlerCoordinator
- type Peer
- type PeerImpl
- func (p *PeerImpl) Broadcast(msg *pb.OpenchainMessage, typ pb.PeerEndpoint_Type) []error
- func (p *PeerImpl) Chat(stream pb.Peer_ChatServer) error
- func (p *PeerImpl) DeregisterHandler(messageHandler MessageHandler) error
- func (p *PeerImpl) ExecuteTransaction(transaction *pb.Transaction) *pb.Response
- func (p *PeerImpl) GetBlockByNumber(blockNumber uint64) (*pb.Block, error)
- func (p *PeerImpl) GetPeerEndpoint() (*pb.PeerEndpoint, error)
- func (p *PeerImpl) GetPeers() (*pb.PeersMessage, error)
- func (p *PeerImpl) GetRemoteLedger(receiverHandle *pb.PeerID) (RemoteLedger, error)
- func (p *PeerImpl) GetSecHelper() crypto.Peer
- func (p *PeerImpl) GetStateDelta(blockNumber uint64) (*statemgmt.StateDelta, error)
- func (p *PeerImpl) GetStateSnapshot() (*state.StateSnapshot, error)
- func (p *PeerImpl) NewOpenchainDiscoveryHello() (*pb.OpenchainMessage, error)
- func (p *PeerImpl) PeersDiscovered(peersMessage *pb.PeersMessage) error
- func (p *PeerImpl) RegisterHandler(messageHandler MessageHandler) error
- func (p *PeerImpl) SendTransactionsToPeer(peerAddress string, transaction *pb.Transaction) *pb.Response
- func (p *PeerImpl) Unicast(msg *pb.OpenchainMessage, receiverHandle *pb.PeerID) error
- type RemoteLedger
- type SecurityAccessor
- type StateAccessor
- type StateRetriever
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLocalAddress ¶
GetLocalAddress returns the address:port the local peer is operating on. Affected by env:peer.addressAutoDetect
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.
Types ¶
type BlockChainAccessor ¶
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
type HandlerFactory ¶
type HandlerFactory func(MessageHandlerCoordinator, ChatStream, bool, MessageHandler) (MessageHandler, error)
type MessageHandler ¶
type MessageHandler interface { RemoteLedger 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 { Peer SecurityAccessor BlockChainAccessor StateAccessor 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 ¶
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 ¶
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.
type RemoteLedger ¶
type RemoteLedger interface { BlocksRetriever StateRetriever }
RemoteLedger interface for retrieving remote ledger data.
type SecurityAccessor ¶
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.