fabric: github.com/hyperledger/fabric/gossip/discovery Index | Files

package discovery

import "github.com/hyperledger/fabric/gossip/discovery"

Index

Package Files

discovery.go discovery_impl.go

Constants

const DefAliveExpirationCheckInterval = DefAliveExpirationTimeout / 10
const DefAliveExpirationTimeout = 5 * DefAliveTimeInterval
const DefAliveTimeInterval = 5 * time.Second
const DefReconnectInterval = DefAliveExpirationTimeout

func HasExternalEndpoint Uses

func HasExternalEndpoint(member NetworkMember) bool

HaveExternalEndpoints selects network members that have external endpoints

func SetMaxConnAttempts Uses

func SetMaxConnAttempts(attempts int)

SetMaxConnAttempts sets the maximum number of connection attempts the peer would perform when invoking Connect()

type CommService Uses

type CommService interface {
    // Gossip gossips a message
    Gossip(msg *protoext.SignedGossipMessage)

    // SendToPeer sends to a given peer a message.
    // The nonce can be anything since the communication module handles the nonce itself
    SendToPeer(peer *NetworkMember, msg *protoext.SignedGossipMessage)

    // Ping probes a remote peer and returns if it's responsive or not
    Ping(peer *NetworkMember) bool

    // Accept returns a read-only channel for membership messages sent from remote peers
    Accept() <-chan protoext.ReceivedMessage

    // PresumedDead returns a read-only channel for peers that are presumed to be dead
    PresumedDead() <-chan common.PKIidType

    // CloseConn orders to close the connection with a certain peer
    CloseConn(peer *NetworkMember)

    // Forward sends message to the next hop, excluding the hop
    // from which message was initially received
    Forward(msg protoext.ReceivedMessage)

    // IdentitySwitch returns a read-only channel about identity change events
    IdentitySwitch() <-chan common.PKIidType
}

CommService is an interface that the discovery expects to be implemented and passed on creation

type CryptoService Uses

type CryptoService interface {
    // ValidateAliveMsg validates that an Alive message is authentic
    ValidateAliveMsg(message *protoext.SignedGossipMessage) bool

    // SignMessage signs a message
    SignMessage(m *proto.GossipMessage, internalEndpoint string) *proto.Envelope
}

CryptoService is an interface that the discovery expects to be implemented and passed on creation

type DisclosurePolicy Uses

type DisclosurePolicy func(remotePeer *NetworkMember) (Sieve, EnvelopeFilter)

DisclosurePolicy defines which messages a given remote peer is eligible of knowing about, and also what is it eligible to know about out of a given SignedGossipMessage. Returns: 1) A Sieve for a given remote peer.

The Sieve is applied for each peer in question and outputs
whether the message should be disclosed to the remote peer.

2) A EnvelopeFilter for a given SignedGossipMessage, which may remove

part of the Envelope the SignedGossipMessage originates from

type Discovery Uses

type Discovery interface {
    // Lookup returns a network member, or nil if not found
    Lookup(PKIID common.PKIidType) *NetworkMember

    // Self returns this instance's membership information
    Self() NetworkMember

    // UpdateMetadata updates this instance's metadata
    UpdateMetadata([]byte)

    // UpdateEndpoint updates this instance's endpoint
    UpdateEndpoint(string)

    // Stops this instance
    Stop()

    // GetMembership returns the alive members in the view
    GetMembership() []NetworkMember

    // InitiateSync makes the instance ask a given number of peers
    // for their membership information
    InitiateSync(peerNum int)

    // Connect makes this instance to connect to a remote instance
    // The identifier param is a function that can be used to identify
    // the peer, and to assert its PKI-ID, whether its in the peer's org or not,
    // and whether the action was successful or not
    Connect(member NetworkMember, id identifier)
}

Discovery is the interface that represents a discovery module

func NewDiscoveryService Uses

func NewDiscoveryService(self NetworkMember, comm CommService, crypt CryptoService, disPol DisclosurePolicy,
    config DiscoveryConfig) Discovery

NewDiscoveryService returns a new discovery service with the comm module passed and the crypto service passed

type DiscoveryConfig Uses

type DiscoveryConfig struct {
    AliveTimeInterval            time.Duration
    AliveExpirationTimeout       time.Duration
    AliveExpirationCheckInterval time.Duration
    ReconnectInterval            time.Duration
    BootstrapPeers               []string
}

type EnvelopeFilter Uses

type EnvelopeFilter func(message *protoext.SignedGossipMessage) *proto.Envelope

EnvelopeFilter may or may not remove part of the Envelope that the given SignedGossipMessage originates from.

type Members Uses

type Members []NetworkMember

Members represents an aggregation of NetworkMembers

func (Members) ByID Uses

func (members Members) ByID() map[string]NetworkMember

ByID returns a mapping from the PKI-IDs (in string form) to NetworkMember

func (Members) Filter Uses

func (members Members) Filter(filter func(member NetworkMember) bool) Members

Filter returns only members that satisfy the given filter

func (Members) Intersect Uses

func (members Members) Intersect(otherMembers Members) Members

Intersect returns the intersection of 2 Members

func (Members) Map Uses

func (members Members) Map(f func(member NetworkMember) NetworkMember) Members

Map invokes the given function to every NetworkMember among the Members

type NetworkMember Uses

type NetworkMember struct {
    Endpoint         string
    Metadata         []byte
    PKIid            common.PKIidType
    InternalEndpoint string
    Properties       *proto.Properties
    *proto.Envelope
}

NetworkMember is a peer's representation

func (NetworkMember) PreferredEndpoint Uses

func (n NetworkMember) PreferredEndpoint() string

PreferredEndpoint computes the endpoint to connect to, while preferring internal endpoint over the standard endpoint

func (NetworkMember) String Uses

func (n NetworkMember) String() string

String returns a string representation of the NetworkMember

type PeerIdentification Uses

type PeerIdentification struct {
    ID      common.PKIidType
    SelfOrg bool
}

PeerIdentification encompasses a remote peer's PKI-ID and whether its in the same org as the current peer or not

type Sieve Uses

type Sieve func(message *protoext.SignedGossipMessage) bool

Sieve defines the messages that are allowed to be sent to some remote peer, based on some criteria. Returns whether the sieve permits sending a given message.

Package discovery imports 13 packages (graph) and is imported by 90 packages. Updated 2019-11-15. Refresh now. Tools for package owners.