gossip

package
v2.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

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
}

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) *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) LeaveChan

func (g *Node) LeaveChan(channelID common.ChannelID)

LeaveChan makes gossip stop participating in the given channel

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) Stop

func (g *Node) Stop()

Stop stops the gossip component

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

func (g *Node) UpdateChaincodes(chaincodes []*pg.Chaincode, channelID common.ChannelID)

UpdateChaincodes updates the chaincodes the peer publishes to other peers in the channel

func (*Node) UpdateLedgerHeight

func (g *Node) UpdateLedgerHeight(height uint64, channelID common.ChannelID)

UpdateLedgerHeight updates the ledger height the peer publishes to other peers in the channel

func (*Node) UpdateMetadata

func (g *Node) UpdateMetadata(md []byte)

UpdateMetadata updates gossip membership metadata.

type SendCriteria added in v1.1.0

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 added in v1.1.0

func (sc SendCriteria) String() string

String returns a string representation of this SendCriteria

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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