mirror of
https://github.com/LBRYFoundation/lbcd.git
synced 2025-08-23 17:47:24 +00:00
Add doc comments.
This commit is contained in:
parent
da2901a4fd
commit
59e2b204a3
1 changed files with 11 additions and 0 deletions
11
server.go
11
server.go
|
@ -200,6 +200,7 @@ func (s *server) handleBroadcastMsg(peers *list.List, bmsg *broadcastMsg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Peerinfo represents the information requested by the getpeerinfo rpc command.
|
||||||
type PeerInfo struct {
|
type PeerInfo struct {
|
||||||
Addr string
|
Addr string
|
||||||
Services btcwire.ServiceFlag
|
Services btcwire.ServiceFlag
|
||||||
|
@ -235,6 +236,8 @@ type delNodeMsg struct {
|
||||||
reply chan error
|
reply chan error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleQuery is the central handler for all queries and commands from other
|
||||||
|
// goroutines related to peer state.
|
||||||
func (s *server) handleQuery(querymsg interface{}, peers *list.List, bannedPeers map[string]time.Time) {
|
func (s *server) handleQuery(querymsg interface{}, peers *list.List, bannedPeers map[string]time.Time) {
|
||||||
switch msg := querymsg.(type) {
|
switch msg := querymsg.(type) {
|
||||||
case getConnCountMsg:
|
case getConnCountMsg:
|
||||||
|
@ -575,6 +578,7 @@ func (s *server) BroadcastMessage(msg btcwire.Message, exclPeers ...*peer) {
|
||||||
s.broadcast <- bmsg
|
s.broadcast <- bmsg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ConnectedCount returns the number of currently connected peers.
|
||||||
func (s *server) ConnectedCount() int {
|
func (s *server) ConnectedCount() int {
|
||||||
replyChan := make(chan int)
|
replyChan := make(chan int)
|
||||||
|
|
||||||
|
@ -583,6 +587,8 @@ func (s *server) ConnectedCount() int {
|
||||||
return <-replyChan
|
return <-replyChan
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PeerInfo returns an array of PeerInfo structures describing all connected
|
||||||
|
// peers.
|
||||||
func (s *server) PeerInfo() []*PeerInfo {
|
func (s *server) PeerInfo() []*PeerInfo {
|
||||||
replyChan := make(chan []*PeerInfo)
|
replyChan := make(chan []*PeerInfo)
|
||||||
|
|
||||||
|
@ -591,6 +597,9 @@ func (s *server) PeerInfo() []*PeerInfo {
|
||||||
return <-replyChan
|
return <-replyChan
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddAddr adds `addr' as a new outbound peer. If permanent is true then the
|
||||||
|
// peer will be persistent and reconnect if the connection is lost.
|
||||||
|
// It is an error to call this with an already existing peer.
|
||||||
func (s *server) AddAddr(addr string, permanent bool) error {
|
func (s *server) AddAddr(addr string, permanent bool) error {
|
||||||
replyChan := make(chan error)
|
replyChan := make(chan error)
|
||||||
|
|
||||||
|
@ -599,6 +608,8 @@ func (s *server) AddAddr(addr string, permanent bool) error {
|
||||||
return <-replyChan
|
return <-replyChan
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RemoveAddr removes `addr' from the list of persistent peers if present.
|
||||||
|
// An error will be returned if the peer was not found.
|
||||||
func (s *server) RemoveAddr(addr string) error {
|
func (s *server) RemoveAddr(addr string) error {
|
||||||
replyChan := make(chan error)
|
replyChan := make(chan error)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue