Skip to content

Commit

Permalink
server: Appropriately name inbound peers map in peerState.
Browse files Browse the repository at this point in the history
Upstream commit 5c59b68.
  • Loading branch information
davecgh committed May 30, 2016
2 parents d3ef588 + 5c59b68 commit 70f6de8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions server.go
Expand Up @@ -109,7 +109,7 @@ type updatePeerHeightsMsg struct {
// as banned peers and outbound groups.
type peerState struct {
pendingPeers map[string]*serverPeer
peers map[int32]*serverPeer
inboundPeers map[int32]*serverPeer
outboundPeers map[int32]*serverPeer
persistentPeers map[int32]*serverPeer
banned map[string]time.Time
Expand All @@ -119,7 +119,8 @@ type peerState struct {

// Count returns the count of all known peers.
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.
Expand Down Expand Up @@ -160,7 +161,7 @@ func (ps *peerState) forPendingPeers(closure func(sp *serverPeer)) {
// forAllPeers is a helper function that runs closure on all peers known to
// peerState.
func (ps *peerState) forAllPeers(closure func(sp *serverPeer)) {
for _, e := range ps.peers {
for _, e := range ps.inboundPeers {
closure(e)
}
ps.forAllOutboundPeers(closure)
Expand Down Expand Up @@ -1282,7 +1283,7 @@ func (s *server) handleAddPeerMsg(state *peerState, sp *serverPeer) bool {
// Add the new peer and start it.
srvrLog.Debugf("New peer %s", sp)
if sp.Inbound() {
state.peers[sp.ID()] = sp
state.inboundPeers[sp.ID()] = sp
} else {
state.outboundGroups[addrmgr.GroupKey(sp.NA())]++
if sp.persistent {
Expand Down Expand Up @@ -1310,7 +1311,7 @@ func (s *server) handleDonePeerMsg(state *peerState, sp *serverPeer) {
if sp.persistent {
list = state.persistentPeers
} else if sp.Inbound() {
list = state.peers
list = state.inboundPeers
} else {
list = state.outboundPeers
}
Expand Down Expand Up @@ -1508,7 +1509,7 @@ func (s *server) handleQuery(state *peerState, querymsg interface{}) {
case disconnectNodeMsg:
// Check inbound peers. We pass a nil callback since we don't
// 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 {
msg.reply <- nil
return
Expand Down Expand Up @@ -1770,7 +1771,7 @@ func (s *server) peerHandler() {

state := &peerState{
pendingPeers: make(map[string]*serverPeer),
peers: make(map[int32]*serverPeer),
inboundPeers: make(map[int32]*serverPeer),
persistentPeers: make(map[int32]*serverPeer),
outboundPeers: make(map[int32]*serverPeer),
banned: make(map[string]time.Time),
Expand Down

0 comments on commit 70f6de8

Please sign in to comment.