improve peer gc efficiency

Instead of separately calculating routes to every individual peer,
carry out one calculation for routes to all peers. Same as unicast
routes except taking into account asymmetric connections.
This commit is contained in:
Matthias Radestock committed 2015-01-27 20:33:13 +00:00
1 parent 6c934f1cd3
commit d88c12caa7
1 file changed
+2 -2
+2 -2
View File
@@ -147,9 +147,9 @@ func (peers *Peers) fetchAlias(peer *Peer) (*Peer, bool) {
func (peers *Peers) garbageCollect() []*Peer {
removed := []*Peer{}
_, reachable := peers.ourself.Routes(nil, false)
for name, peer := range peers.table {
found, _ := peers.ourself.Routes(peer, false)
if !found && !peer.IsLocallyReferenced() {
if _, found := reachable[peer.Name]; !found && !peer.IsLocallyReferenced() {
delete(peers.table, name)
peers.onGC(peer)
removed = append(removed, peer)