Documentation ¶
Index ¶
- type Config
- type Node
- func (g *Node) Accept(acceptor common.MessageAcceptor, passThrough bool) (<-chan *pg.GossipMessage, <-chan protoext.ReceivedMessage)
- func (g *Node) Gossip(msg *pg.GossipMessage)
- func (g *Node) IdentityInfo() api.PeerIdentitySet
- func (g *Node) IsInMyOrg(member discovery.NetworkMember) bool
- func (g *Node) JoinChan(joinMsg api.JoinChannelMessage, channelID common.ChannelID)
- func (g *Node) LeaveChan(channelID common.ChannelID)
- func (g *Node) PeerFilter(channel common.ChannelID, messagePredicate api.SubChannelSelectionCriteria) (filter.RoutingFilter, error)
- func (g *Node) Peers() []discovery.NetworkMember
- func (g *Node) PeersOfChannel(channel common.ChannelID) []discovery.NetworkMember
- func (g *Node) SelfChannelInfo(chain common.ChannelID) *protoext.SignedGossipMessage
- func (g *Node) SelfMembershipInfo() discovery.NetworkMember
- func (g *Node) Send(msg *pg.GossipMessage, peers ...*comm.RemotePeer)
- func (g *Node) SendByCriteria(msg *protoext.SignedGossipMessage, criteria SendCriteria) error
- func (g *Node) Stop()
- func (g *Node) SuspectPeers(isSuspected api.PeerSuspector)
- func (g *Node) UpdateChaincodes(chaincodes []*pg.Chaincode, channelID common.ChannelID)
- func (g *Node) UpdateLedgerHeight(height uint64, channelID common.ChannelID)
- func (g *Node) UpdateMetadata(md []byte)
- type SendCriteria
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // BindPort is the port that gossip bind to, used only for tests. BindPort int // Id of the specific gossip instance. ID string // BootstrapPeers are peers we connect to at startup. BootstrapPeers []string // PropagateIterations is the number of times a message is pushed to remote peers. PropagateIterations int // PropagatePeerNum is the number of peers selected to push messages to. PropagatePeerNum int // MaxBlockCountToStore is the maximum count of blocks we store in memory. MaxBlockCountToStore int // MaxPropagationBurstSize is the max number of messages stored until it triggers a push to remote peers. MaxPropagationBurstSize int // MaxPropagationBurstLatency is the max time between consecutive message pushes. MaxPropagationBurstLatency time.Duration // PullInterval determines frequency of pull phases. PullInterval time.Duration // PullPeerNum is the number of peers to pull from. PullPeerNum int // SkipBlockVerification controls either we skip verifying block message or not. SkipBlockVerification bool // PublishCertPeriod is the time from startup certificates are included in Alive message. PublishCertPeriod time.Duration // PublishStateInfoInterval determines frequency of pushing state info messages to peers. PublishStateInfoInterval time.Duration // RequestStateInfoInterval determines frequency of pulling state info messages from peers. RequestStateInfoInterval time.Duration // TLSCerts is the TLS certificates of the peer. TLSCerts *common.TLSCertificates // InternalEndpoint is the endpoint we publish to peers in our organization. InternalEndpoint string // ExternalEndpoint is the peer publishes this endpoint instead of selfEndpoint to foreign organizations. ExternalEndpoint string // TimeForMembershipTracker determines time for polloing with membershipTracker. TimeForMembershipTracker time.Duration // DigestWaitTime is the time to wait before pull engine processes incoming digests. DigestWaitTime time.Duration // RequestWaitTime is the time to wait before pull engine removes incoming nonce. RequestWaitTime time.Duration // ResponseWaitTime is the time to wait before pull engine ends pull. ResponseWaitTime time.Duration // DialTimeout indicate Dial timeout. DialTimeout time.Duration // ConnTimeout indicate Connection timeout. ConnTimeout time.Duration // RecvBuffSize is the buffer size of received message. RecvBuffSize int // SendBuffSize is the buffer size of sending message. SendBuffSize int // MsgExpirationTimeout indicate leadership message expiration timeout. MsgExpirationTimeout time.Duration // AliveTimeInterval is the alive check interval. AliveTimeInterval time.Duration // AliveExpirationTimeout is the alive expiration timeout. AliveExpirationTimeout time.Duration // AliveExpirationCheckInterval is the alive expiration check interval. AliveExpirationCheckInterval time.Duration // ReconnectInterval is the Reconnect interval. ReconnectInterval time.Duration // MsgExpirationFactor is the expiration factor for alive message TTL MsgExpirationFactor int // MaxConnectionAttempts is the max number of attempts to connect to a peer (wait for alive ack) MaxConnectionAttempts int }
Config is the configuration of the gossip component
func GlobalConfig ¶
func GlobalConfig(endpoint string, certs *common.TLSCertificates, bootPeers ...string) (*Config, error)
GlobalConfig builds a Config from the given endpoint, certificate and bootstrap peers.
type Node ¶
type Node struct { *comm.ChannelDeMultiplexer // contains filtered or unexported fields }
Node is a member of a gossip network
func New ¶
func New(conf *Config, s *grpc.Server, sa api.SecurityAdvisor, mcs api.MessageCryptoService, selfIdentity api.PeerIdentityType, secureDialOpts api.PeerSecureDialOpts, gossipMetrics *metrics.GossipMetrics, anchorPeerTracker discovery.AnchorPeerTracker) *Node
New creates a gossip instance attached to a gRPC server
func (*Node) Accept ¶
func (g *Node) Accept(acceptor common.MessageAcceptor, passThrough bool) (<-chan *pg.GossipMessage, <-chan protoext.ReceivedMessage)
Accept returns a dedicated read-only channel for messages sent by other nodes that match a certain predicate. If passThrough is false, the messages are processed by the gossip layer beforehand. If passThrough is true, the gossip layer doesn't intervene and the messages can be used to send a reply back to the sender
func (*Node) Gossip ¶
func (g *Node) Gossip(msg *pg.GossipMessage)
Gossip sends a message to other peers to the network
func (*Node) IdentityInfo ¶
func (g *Node) IdentityInfo() api.PeerIdentitySet
IdentityInfo returns information known peer identities
func (*Node) IsInMyOrg ¶
func (g *Node) IsInMyOrg(member discovery.NetworkMember) bool
IsInMyOrg checks whether a network member is in this peer's org
func (*Node) JoinChan ¶
func (g *Node) JoinChan(joinMsg api.JoinChannelMessage, channelID common.ChannelID)
JoinChan makes gossip participate in the given channel, or update it.
func (*Node) PeerFilter ¶
func (g *Node) PeerFilter(channel common.ChannelID, messagePredicate api.SubChannelSelectionCriteria) (filter.RoutingFilter, error)
PeerFilter receives a SubChannelSelectionCriteria and returns a RoutingFilter that selects only peer identities that match the given criteria, and that they published their channel participation
func (*Node) Peers ¶
func (g *Node) Peers() []discovery.NetworkMember
Peers returns the current alive NetworkMembers
func (*Node) PeersOfChannel ¶
func (g *Node) PeersOfChannel(channel common.ChannelID) []discovery.NetworkMember
PeersOfChannel returns the NetworkMembers considered alive and also subscribed to the channel given
func (*Node) SelfChannelInfo ¶
func (g *Node) SelfChannelInfo(chain common.ChannelID) *protoext.SignedGossipMessage
SelfChannelInfo returns the peer's latest StateInfo message of a given channel
func (*Node) SelfMembershipInfo ¶
func (g *Node) SelfMembershipInfo() discovery.NetworkMember
SelfMembershipInfo returns the peer's membership information
func (*Node) Send ¶
func (g *Node) Send(msg *pg.GossipMessage, peers ...*comm.RemotePeer)
Send sends a message to remote peers
func (*Node) SendByCriteria ¶
func (g *Node) SendByCriteria(msg *protoext.SignedGossipMessage, criteria SendCriteria) error
SendByCriteria sends a given message to all peers that match the given SendCriteria
func (*Node) SuspectPeers ¶
func (g *Node) SuspectPeers(isSuspected api.PeerSuspector)
SuspectPeers makes the gossip instance validate identities of suspected peers, and close any connections to peers with identities that are found invalid
func (*Node) UpdateChaincodes ¶
UpdateChaincodes updates the chaincodes the peer publishes to other peers in the channel
func (*Node) UpdateLedgerHeight ¶
UpdateLedgerHeight updates the ledger height the peer publishes to other peers in the channel
func (*Node) UpdateMetadata ¶
UpdateMetadata updates gossip membership metadata.
type SendCriteria ¶
type SendCriteria struct { Timeout time.Duration // Timeout defines the time to wait for acknowledgements MinAck int // MinAck defines the amount of peers to collect acknowledgements from MaxPeers int // MaxPeers defines the maximum number of peers to send the message to IsEligible filter.RoutingFilter // IsEligible defines whether a specific peer is eligible of receiving the message Channel common.ChannelID // Channel specifies a channel to send this message on. \ }
SendCriteria defines how to send a specific message
func (SendCriteria) String ¶
func (sc SendCriteria) String() string
String returns a string representation of this SendCriteria