1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-29 17:36:38 +08:00

Drop -> CloseConnection

This commit is contained in:
Juan Batiz-Benet
2014-08-30 00:00:52 -07:00
committed by Brian Tiger Chow
parent d934806eaf
commit 71ec4f91dc
3 changed files with 5 additions and 5 deletions

View File

@ -521,7 +521,7 @@ func (dht *IpfsDHT) putLocal(key u.Key, value []byte) error {
func (dht *IpfsDHT) Update(p *peer.Peer) { func (dht *IpfsDHT) Update(p *peer.Peer) {
for _, route := range dht.routingTables { for _, route := range dht.routingTables {
removed := route.Update(p) removed := route.Update(p)
// Only drop the connection if no tables refer to this peer // Only close the connection if no tables refer to this peer
if removed != nil { if removed != nil {
found := false found := false
for _, r := range dht.routingTables { for _, r := range dht.routingTables {
@ -531,7 +531,7 @@ func (dht *IpfsDHT) Update(p *peer.Peer) {
} }
} }
if !found { if !found {
dht.network.Drop(removed) dht.network.CloseConnection(removed)
} }
} }
} }

View File

@ -16,5 +16,5 @@ type Network interface {
GetErrChan() chan error GetErrChan() chan error
GetChannel(PBWrapper_MessageType) *Chan GetChannel(PBWrapper_MessageType) *Chan
Close() Close()
Drop(*peer.Peer) error CloseConnection(*peer.Peer) error
} }

View File

@ -467,8 +467,8 @@ func (s *Swarm) ConnectNew(addr *ma.Multiaddr) (*peer.Peer, error) {
return npeer, err return npeer, err
} }
// Removes a given peer from the swarm and closes connections to it // CloseConnection removes a given peer from swarm + closes the connection
func (s *Swarm) Drop(p *peer.Peer) error { func (s *Swarm) CloseConnection(p *peer.Peer) error {
u.DOut("Dropping peer: [%s]\n", p.ID.Pretty()) u.DOut("Dropping peer: [%s]\n", p.ID.Pretty())
s.connsLock.RLock() s.connsLock.RLock()
conn, found := s.conns[u.Key(p.ID)] conn, found := s.conns[u.Key(p.ID)]