Documentation
¶
Index ¶
- type ByID
- type ByPubHex
- type IdPeers
- type JSONPeers
- type Peer
- type PeerStore
- type Peers
- func (p *Peers) AddPeer(peer *Peer)
- func (p *Peers) Len() int
- func (p *Peers) RemovePeer(peer *Peer)
- func (p *Peers) RemovePeerById(id int)
- func (p *Peers) RemovePeerByPubKey(pubKey string)
- func (p *Peers) ToIDSlice() []int
- func (p *Peers) ToPeerSlice() []*Peer
- func (p *Peers) ToPubKeySlice() []string
- type PubKeyPeers
- type StaticPeers
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ByPubHex ¶
type ByPubHex []*Peer
ByPubHex implements sort.Interface for Peers based on the PubKeyHex field.
type JSONPeers ¶
type JSONPeers struct {
// contains filtered or unexported fields
}
JSONPeers is used to provide peer persistence on disk in the form of a JSON file. This allows human operators to manipulate the file.
func NewJSONPeers ¶
NewJSONPeers creates a new JSONPeers store.
type Peer ¶
func ExcludePeer ¶
ExcludePeer is used to exclude a single peer from a list of peers.
func (*Peer) PubKeyBytes ¶
type PeerStore ¶
type PeerStore interface { // Peers returns the list of known peers. Peers() (*Peers, error) // SetPeers sets the list of known peers. This is invoked when a peer is // added or removed. SetPeers([]*Peer) error }
PeerStore provides an interface for persistent storage and retrieval of peers.
type Peers ¶
type Peers struct { sync.RWMutex Sorted []*Peer ByPubKey PubKeyPeers ById IdPeers }
func NewPeersFromSlice ¶
func (*Peers) RemovePeer ¶
func (*Peers) RemovePeerById ¶
func (*Peers) RemovePeerByPubKey ¶
func (*Peers) ToPeerSlice ¶
func (*Peers) ToPubKeySlice ¶
type PubKeyPeers ¶
type StaticPeers ¶
type StaticPeers struct { StaticPeers []Peer // contains filtered or unexported fields }
StaticPeers is used to provide a static list of peers.
func (*StaticPeers) Peers ¶
func (s *StaticPeers) Peers() ([]Peer, error)
Peers implements the PeerStore interface.
func (*StaticPeers) SetPeers ¶
func (s *StaticPeers) SetPeers(p []Peer) error
SetPeers implements the PeerStore interface.
Click to show internal directories.
Click to hide internal directories.