Documentation ¶
Index ¶
- Constants
- Variables
- func NewCredQuery() *pb.Message
- func NewPeerClientConnectionWithAddress(peerAddress string) (*grpc.ClientConn, error)
- func SetLegacyEngine(e Engine)
- type ChatStream
- type Discoverer
- type DuplicateHandlerError
- type Engine
- type Handler
- func (d *Handler) Credential() cred.PeerCred
- func (d *Handler) GetStream() ChatStream
- func (d *Handler) HandleMessage(msg *pb.Message) error
- func (d *Handler) IsGlareWeak(self *pb.PeerID) bool
- func (d *Handler) SendMessage(msg *pb.Message) error
- func (d *Handler) Stop() error
- func (d *Handler) To() (pb.PeerEndpoint, error)
- type Impl
- func (p *Impl) AddStreamStub(name string, factory pb.StreamHandlerFactory, opts ...interface{}) error
- func (p *Impl) Broadcast(msg *pb.Message, typ pb.PeerEndpoint_Type) []error
- func (p *Impl) Chat(stream pb.Peer_ChatServer) error
- func (p *Impl) DeregisterHandler(messageHandler MessageHandler) error
- func (p *Impl) EndPeer()
- func (p *Impl) GetACL() (acl.AccessControl, error)
- func (p *Impl) GetDiscHelper() discovery.Discovery
- func (p *Impl) GetDiscoverer() (Discoverer, error)
- func (p *Impl) GetNeighbour() (Neighbour, error)
- func (p *Impl) GetPeerCtx() context.Context
- func (p *Impl) GetPeerEndpoint() (*pb.PeerEndpoint, error)
- func (p *Impl) GetPeers() (*pb.PeersMessage, error)
- func (p *Impl) GetStreamStub(name string) *pb.StreamStub
- func (p *Impl) PeersDiscovered(peersMessage *pb.PeersMessage) error
- func (p *Impl) ProcessTransaction(context.Context, *pb.Transaction) (*pb.Response, error)
- func (p *Impl) RegisterHandler(ctx context.Context, initiated bool, messageHandler MessageHandler) error
- func (p *Impl) RunPeer(config *PeerConfig)
- func (p *Impl) SendTransactionsToPeer(peerAddress string, transaction *pb.Transaction) (response *pb.Response)
- func (p *Impl) Unicast(msg *pb.Message, receiverHandle *pb.PeerID) error
- type LegacyMessageHandler
- type MessageHandler
- type Neighbour
- type Peer
- type PeerConfig
- type StreamFilter
- type StreamPostHandler
- type TransactionProccesor
Constants ¶
const DefaultSyncSnapshotTimeout time.Duration = 60 * time.Second
Variables ¶
var PeerGlobalParentCtx = context.Background()
Functions ¶
func NewCredQuery ¶
func NewPeerClientConnectionWithAddress ¶
func NewPeerClientConnectionWithAddress(peerAddress string) (*grpc.ClientConn, error)
NewPeerClientConnectionWithAddress Returns a new grpc.ClientConn to the configured PEER.
func SetLegacyEngine ¶
func SetLegacyEngine(e Engine)
Types ¶
type ChatStream ¶
type ChatStream interface { Send(*pb.Message) error Recv() (*pb.Message, error) Context() context.Context //this can be called externally and stop current stream (Recv will be interrupted and //return non io.EOF error) Close() }
ChatStream interface supported by stream between Peers
type Discoverer ¶
Discoverer enables a peer to access/persist/restore its discovery list
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 HandlerFactory(MessageHandler) (LegacyMessageHandler, error) }
type Handler ¶
type Handler struct { ToPeerEndpoint *pb.PeerEndpoint Coordinator *Impl ChatStream ChatStream FSM *fsm.FSM // contains filtered or unexported fields }
Handler peer handler implementation.
func (*Handler) Credential ¶
func (*Handler) GetStream ¶
func (d *Handler) GetStream() ChatStream
func (*Handler) HandleMessage ¶
HandleMessage handles the Openchain messages for the Peer.
func (*Handler) SendMessage ¶
SendMessage sends a message to the remote PEER through the stream
type Impl ¶
type Impl struct {
// contains filtered or unexported fields
}
Impl implementation of the Peer service
func CreateNewPeer ¶
func CreateNewPeer(cred cred.PeerCreds, config *PeerConfig) (peer *Impl, err error)
NewPeerWithEngine returns a Peer which uses the supplied handler factory function for creating new handlers on new Chat service invocations.
func NewPeer ¶
func NewPeer(self *pb.PeerEndpoint) *Impl
func (*Impl) AddStreamStub ¶
func (p *Impl) AddStreamStub(name string, factory pb.StreamHandlerFactory, opts ...interface{}) error
func (*Impl) Broadcast ¶
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 (*Impl) Chat ¶
func (p *Impl) Chat(stream pb.Peer_ChatServer) error
Chat implementation of the the Chat bidi streaming RPC function
func (*Impl) DeregisterHandler ¶
func (p *Impl) DeregisterHandler(messageHandler MessageHandler) error
DeregisterHandler deregisters an already registered MessageHandler for this coordinator
func (*Impl) GetDiscHelper ¶
func (*Impl) GetDiscoverer ¶
func (p *Impl) GetDiscoverer() (Discoverer, error)
func (*Impl) GetNeighbour ¶
func (*Impl) GetPeerCtx ¶
func (*Impl) GetPeerEndpoint ¶
func (p *Impl) GetPeerEndpoint() (*pb.PeerEndpoint, error)
GetPeerEndpoint returns the endpoint for this peer
func (*Impl) GetPeers ¶
func (p *Impl) GetPeers() (*pb.PeersMessage, error)
GetPeers returns the currently registered PeerEndpoints which are also in peer discovery list
func (*Impl) GetStreamStub ¶
func (p *Impl) GetStreamStub(name string) *pb.StreamStub
func (*Impl) PeersDiscovered ¶
func (p *Impl) PeersDiscovered(peersMessage *pb.PeersMessage) error
PeersDiscovered used by MessageHandlers for notifying this coordinator of discovered PeerEndoints. May include this Peer's PeerEndpoint.
func (*Impl) ProcessTransaction ¶
func (*Impl) RegisterHandler ¶
func (p *Impl) RegisterHandler(ctx context.Context, initiated bool, messageHandler MessageHandler) error
RegisterHandler register a MessageHandler with this coordinator
func (*Impl) RunPeer ¶
func (p *Impl) RunPeer(config *PeerConfig)
func (*Impl) SendTransactionsToPeer ¶
func (p *Impl) SendTransactionsToPeer(peerAddress string, transaction *pb.Transaction) (response *pb.Response)
---- deprecated ----- SendTransactionsToPeer forwards transactions to the specified peer address.
type LegacyMessageHandler ¶
type MessageHandler ¶
type MessageHandler interface { LegacyMessageHandler SendMessage(msg *pb.Message) error GetStream() ChatStream To() (pb.PeerEndpoint, error) Credential() cred.PeerCred //test if current connection is "glare weak", if so, it will be replaced //by a "glare strong" incoming connection, a glare weak is determinded //in both side (i.e. it is weak in oneside will be also weak in another side) IsGlareWeak(self *pb.PeerID) bool Stop() error }
MessageHandler standard interface for handling Openchain messages.
func NewPeerHandler ¶
func NewPeerHandler(coord *Impl, stream ChatStream, initiatedStream bool, peerCred cred.PeerCred) (MessageHandler, error)
NewPeerHandler returns a new Peer handler Is instance of HandlerFactory
type Neighbour ¶
type Neighbour interface { Broadcast(*pb.Message, pb.PeerEndpoint_Type) []error Unicast(*pb.Message, *pb.PeerID) error GetPeerEndpoint() (*pb.PeerEndpoint, error) //for convinient, we also include this method GetPeers() (*pb.PeersMessage, error) GetDiscoverer() (Discoverer, error) GetACL() (acl.AccessControl, error) }
type Peer ¶
type Peer interface { GetPeerEndpoint() (*pb.PeerEndpoint, error) GetNeighbour() (Neighbour, error) //init stream stubs, with options ... AddStreamStub(string, pb.StreamHandlerFactory, ...interface{}) error GetStreamStub(string) *pb.StreamStub GetPeerCtx() context.Context }
Peer provides interface for a peer
type PeerConfig ¶
type PeerConfig struct { PeerTag string IsValidator bool PeerEndpoint *pb.PeerEndpoint Discovery struct { Roots []string Persist bool Hidden bool Disable bool TouchPeriod time.Duration MaxNodes int } NewPeerClientConn func(string) (*grpc.ClientConn, error) }
func NewPeerConfig ¶
func NewPeerConfig(forValidator bool, vp *viper.Viper, spec *config.ServerSpec) (*PeerConfig, error)
func (*PeerConfig) Configuration ¶
func (c *PeerConfig) Configuration(vp *viper.Viper, spec *config.ServerSpec) error
type StreamFilter ¶
type StreamFilter interface {
QualitifiedPeer(*pb.PeerEndpoint) bool
}
type StreamPostHandler ¶
type StreamPostHandler interface {
NotifyNewPeer(*pb.PeerID, *pb.StreamStub)
}