server: Appropriately name inbound peers map in peerState.
This commit is contained in:
parent
f389742b39
commit
5c59b685e6
1 changed files with 8 additions and 7 deletions
15
server.go
15
server.go
|
@ -106,7 +106,7 @@ type updatePeerHeightsMsg struct {
|
||||||
// as banned peers and outbound groups.
|
// as banned peers and outbound groups.
|
||||||
type peerState struct {
|
type peerState struct {
|
||||||
pendingPeers map[string]*serverPeer
|
pendingPeers map[string]*serverPeer
|
||||||
peers map[int32]*serverPeer
|
inboundPeers map[int32]*serverPeer
|
||||||
outboundPeers map[int32]*serverPeer
|
outboundPeers map[int32]*serverPeer
|
||||||
persistentPeers map[int32]*serverPeer
|
persistentPeers map[int32]*serverPeer
|
||||||
banned map[string]time.Time
|
banned map[string]time.Time
|
||||||
|
@ -116,7 +116,8 @@ type peerState struct {
|
||||||
|
|
||||||
// Count returns the count of all known peers.
|
// Count returns the count of all known peers.
|
||||||
func (ps *peerState) Count() int {
|
func (ps *peerState) Count() int {
|
||||||
return len(ps.peers) + len(ps.outboundPeers) + len(ps.persistentPeers)
|
return len(ps.inboundPeers) + len(ps.outboundPeers) +
|
||||||
|
len(ps.persistentPeers)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OutboundCount returns the count of known outbound peers.
|
// OutboundCount returns the count of known outbound peers.
|
||||||
|
@ -157,7 +158,7 @@ func (ps *peerState) forPendingPeers(closure func(sp *serverPeer)) {
|
||||||
// forAllPeers is a helper function that runs closure on all peers known to
|
// forAllPeers is a helper function that runs closure on all peers known to
|
||||||
// peerState.
|
// peerState.
|
||||||
func (ps *peerState) forAllPeers(closure func(sp *serverPeer)) {
|
func (ps *peerState) forAllPeers(closure func(sp *serverPeer)) {
|
||||||
for _, e := range ps.peers {
|
for _, e := range ps.inboundPeers {
|
||||||
closure(e)
|
closure(e)
|
||||||
}
|
}
|
||||||
ps.forAllOutboundPeers(closure)
|
ps.forAllOutboundPeers(closure)
|
||||||
|
@ -1137,7 +1138,7 @@ func (s *server) handleAddPeerMsg(state *peerState, sp *serverPeer) bool {
|
||||||
// Add the new peer and start it.
|
// Add the new peer and start it.
|
||||||
srvrLog.Debugf("New peer %s", sp)
|
srvrLog.Debugf("New peer %s", sp)
|
||||||
if sp.Inbound() {
|
if sp.Inbound() {
|
||||||
state.peers[sp.ID()] = sp
|
state.inboundPeers[sp.ID()] = sp
|
||||||
} else {
|
} else {
|
||||||
state.outboundGroups[addrmgr.GroupKey(sp.NA())]++
|
state.outboundGroups[addrmgr.GroupKey(sp.NA())]++
|
||||||
if sp.persistent {
|
if sp.persistent {
|
||||||
|
@ -1165,7 +1166,7 @@ func (s *server) handleDonePeerMsg(state *peerState, sp *serverPeer) {
|
||||||
if sp.persistent {
|
if sp.persistent {
|
||||||
list = state.persistentPeers
|
list = state.persistentPeers
|
||||||
} else if sp.Inbound() {
|
} else if sp.Inbound() {
|
||||||
list = state.peers
|
list = state.inboundPeers
|
||||||
} else {
|
} else {
|
||||||
list = state.outboundPeers
|
list = state.outboundPeers
|
||||||
}
|
}
|
||||||
|
@ -1363,7 +1364,7 @@ func (s *server) handleQuery(state *peerState, querymsg interface{}) {
|
||||||
case disconnectNodeMsg:
|
case disconnectNodeMsg:
|
||||||
// Check inbound peers. We pass a nil callback since we don't
|
// Check inbound peers. We pass a nil callback since we don't
|
||||||
// require any additional actions on disconnect for inbound peers.
|
// require any additional actions on disconnect for inbound peers.
|
||||||
found := disconnectPeer(state.peers, msg.cmp, nil)
|
found := disconnectPeer(state.inboundPeers, msg.cmp, nil)
|
||||||
if found {
|
if found {
|
||||||
msg.reply <- nil
|
msg.reply <- nil
|
||||||
return
|
return
|
||||||
|
@ -1629,7 +1630,7 @@ func (s *server) peerHandler() {
|
||||||
|
|
||||||
state := &peerState{
|
state := &peerState{
|
||||||
pendingPeers: make(map[string]*serverPeer),
|
pendingPeers: make(map[string]*serverPeer),
|
||||||
peers: make(map[int32]*serverPeer),
|
inboundPeers: make(map[int32]*serverPeer),
|
||||||
persistentPeers: make(map[int32]*serverPeer),
|
persistentPeers: make(map[int32]*serverPeer),
|
||||||
outboundPeers: make(map[int32]*serverPeer),
|
outboundPeers: make(map[int32]*serverPeer),
|
||||||
banned: make(map[string]time.Time),
|
banned: make(map[string]time.Time),
|
||||||
|
|
Loading…
Add table
Reference in a new issue