discovery

package
Version: v0.0.0-...-667e438 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Discovery

type Discovery interface {
	AddNode(string) bool           // Add an address to the discovery list
	ResumeNode(string)             // Add or resume existed address from discovery list
	RemoveNode(string) bool        // Remove an address from the discovery list
	AddNodes([]string) []string    // Add a batch of address, and return which is added
	GetAllNodes() []string         // Return all addresses this peer maintains
	GetRandomNode() string         // Return n random addresses for this peer to connect t
	GetRandomNodes(n int) []string // Return n random addresses for this peer to connect to
	FindNode(string) bool          // Find a node in the discovery list
	DiscoveryPersistor
}

Discovery is the interface that consolidates bootstrap peer membership selection and validating peer selection for non-validating peers

type DiscoveryImpl

type DiscoveryImpl struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

DiscoveryImpl is an implementation of Discovery

func NewDiscoveryImpl

func NewDiscoveryImpl() *DiscoveryImpl

NewDiscoveryImpl is a constructor of a Discovery implementation

func (*DiscoveryImpl) AddNode

func (di *DiscoveryImpl) AddNode(address string) bool

AddNode adds an address to the discovery list

func (*DiscoveryImpl) AddNodes

func (di *DiscoveryImpl) AddNodes(addrs []string) []string

func (*DiscoveryImpl) FindNode

func (di *DiscoveryImpl) FindNode(address string) bool

FindNode returns true if its address is stored in the discovery list

func (*DiscoveryImpl) GetAllNodes

func (di *DiscoveryImpl) GetAllNodes() []string

GetAllNodes returns an array of all addresses saved in the discovery list

func (*DiscoveryImpl) GetRandomNode

func (di *DiscoveryImpl) GetRandomNode() string

func (*DiscoveryImpl) GetRandomNodes

func (di *DiscoveryImpl) GetRandomNodes(n int) []string

GetRandomNodes returns n random nodes YA-fabric 0.9: it has a stupid implement so now it just return 1 random node

func (*DiscoveryImpl) LoadDiscoveryList

func (di *DiscoveryImpl) LoadDiscoveryList(k db.PersistorKey) error

LoadDiscoveryList enables a peer to load the discovery list from the database

func (*DiscoveryImpl) RemoveNode

func (di *DiscoveryImpl) RemoveNode(address string) bool

RemoveNode removes an address from the discovery list

func (*DiscoveryImpl) ResumeNode

func (di *DiscoveryImpl) ResumeNode(address string)

func (*DiscoveryImpl) StoreDiscoveryList

func (di *DiscoveryImpl) StoreDiscoveryList(k db.PersistorKey) error

StoreDiscoveryList enables a peer to persist the discovery list to the database

type DiscoveryPersistor

type DiscoveryPersistor interface {
	LoadDiscoveryList(db.PersistorKey) error
	StoreDiscoveryList(db.PersistorKey) error
}

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL