refactor(ish): move a bunch of methods from Peer to LocalPeer

in order to reduce the former's API surface
This commit is contained in:
Matthias Radestock committed 2015-05-11 17:19:15 +01:00
1 parent 52a89a318a
commit 3e6eef5ebd
6 files changed
+38 -36

No files matched your search

-26
View File
@@ -66,12 +66,6 @@ func (peer *Peer) IsLocallyReferenced() bool {
return peer.localRefCount != 0
}
func (peer *Peer) ConnectionCount() int {
peer.RLock()
defer peer.RUnlock()
return len(peer.connections)
}
func (peer *Peer) ConnectionTo(name PeerName) (Connection, bool) {
peer.RLock()
defer peer.RUnlock()
@@ -96,26 +90,6 @@ func (peer *Peer) SetVersionAndConnections(version uint64, connections map[PeerN
peer.connections = connections
}
func (peer *Peer) addConnection(conn Connection) {
peer.Lock()
defer peer.Unlock()
peer.connections[conn.Remote().Name] = conn
peer.version++
}
func (peer *Peer) deleteConnection(conn Connection) {
peer.Lock()
defer peer.Unlock()
delete(peer.connections, conn.Remote().Name)
peer.version++
}
func (peer *Peer) connectionEstablished(conn Connection) {
peer.Lock()
defer peer.Unlock()
peer.version++
}
// Calculate the routing table from this peer to all peers reachable
// from it, returning a "next hop" map of PeerNameX -> PeerNameY,
// which says "in order to send a message to X, the peer should send