discovery

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Discovery

type Discovery struct {
	// contains filtered or unexported fields
}

Discovery provides functions to retrieve info about the local peer and other peers in a given channel

func New

func New(channelID string, gossip gossipAdapter) *Discovery

New returns a new Discovery

func (*Discovery) ChannelID

func (r *Discovery) ChannelID() string

ChannelID returns the channel ID

func (*Discovery) GetMSPID

func (r *Discovery) GetMSPID(pkiID common.PKIidType) (string, bool)

GetMSPID gets the MSP id

func (*Discovery) GetMembers

func (r *Discovery) GetMembers(accept filter) []*Member

GetMembers returns members filtered by the given filter

func (*Discovery) Self

func (r *Discovery) Self() *Member

Self returns the local peer

type Member

type Member struct {
	discovery.NetworkMember
	ChannelID string
	MSPID     string
	Local     bool // Indicates whether this member is the local peer
}

Member wraps a NetworkMember and provides additional info

func (*Member) HasRole

func (m *Member) HasRole(role roles.Role) bool

HasRole returns true if the member has the given role

func (*Member) Roles

func (m *Member) Roles() roles.Roles

Roles returns the roles of the peer

func (*Member) String

func (m *Member) String() string

type PeerGroup

type PeerGroup []*Member

PeerGroup is a group of peers

func Merge

func Merge(g PeerGroup, peers ...*Member) PeerGroup

Merge adds the given peers to the group if they don't already exist

func (PeerGroup) Contains

func (g PeerGroup) Contains(peer *Member) bool

Contains returns true if the given peer is contained within this peer group

func (PeerGroup) ContainsAll

func (g PeerGroup) ContainsAll(peerGroup PeerGroup) bool

ContainsAll returns true if ALL of the peers within the given peer group are contained within this peer group

func (PeerGroup) ContainsAny

func (g PeerGroup) ContainsAny(peerGroup PeerGroup) bool

ContainsAny returns true if ANY of the peers within the given peer group are contained within this peer group

func (PeerGroup) ContainsLocal

func (g PeerGroup) ContainsLocal() bool

ContainsLocal return true if one of the peers in the group is the local peer

func (PeerGroup) ContainsPeer

func (g PeerGroup) ContainsPeer(endpoint string) bool

ContainsPeer returns true if the given peer is contained within this peer group

func (PeerGroup) ContainsRemote added in v0.1.6

func (g PeerGroup) ContainsRemote() bool

ContainsRemote return true if one or more of the peers in the group is a remote peer

func (PeerGroup) Len

func (g PeerGroup) Len() int

func (PeerGroup) Less

func (g PeerGroup) Less(i, j int) bool

func (PeerGroup) Local

func (g PeerGroup) Local() (*Member, bool)

Local returns the local peer from the group

func (PeerGroup) Remote

func (g PeerGroup) Remote() PeerGroup

Remote returns a PeerGroup subset that only includes remote peers

func (PeerGroup) Shuffle

func (g PeerGroup) Shuffle() PeerGroup

Shuffle returns a randomly shuffled PeerGroup

func (PeerGroup) Sort

func (g PeerGroup) Sort() PeerGroup

Sort sorts the peer group by endpoint

func (PeerGroup) String

func (g PeerGroup) String() string

func (PeerGroup) Swap

func (g PeerGroup) Swap(i, j int)

Jump to

Keyboard shortcuts

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