Documentation ¶
Index ¶
- type Discovery
- type DiscoveryImpl
- func (di *DiscoveryImpl) AddNode(address string) bool
- func (di *DiscoveryImpl) AddNodes(addrs []string) []string
- func (di *DiscoveryImpl) FindNode(address string) bool
- func (di *DiscoveryImpl) GetAllNodes() []string
- func (di *DiscoveryImpl) GetRandomNode() string
- func (di *DiscoveryImpl) GetRandomNodes(n int) []string
- func (di *DiscoveryImpl) LoadDiscoveryList(k db.PersistorKey) error
- func (di *DiscoveryImpl) RemoveNode(address string) bool
- func (di *DiscoveryImpl) ResumeNode(address string)
- func (di *DiscoveryImpl) StoreDiscoveryList(k db.PersistorKey) error
- type DiscoveryPersistor
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 ¶
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 }