2015-01-24 08:52:01 -08:00
|
|
|
package dht
|
|
|
|
|
|
|
|
import (
|
2015-01-30 20:17:55 -08:00
|
|
|
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
|
|
|
|
|
2015-01-24 08:52:01 -08:00
|
|
|
inet "github.com/jbenet/go-ipfs/p2p/net"
|
|
|
|
)
|
|
|
|
|
|
|
|
// netNotifiee defines methods to be used with the IpfsDHT
|
|
|
|
type netNotifiee IpfsDHT
|
|
|
|
|
|
|
|
func (nn *netNotifiee) DHT() *IpfsDHT {
|
|
|
|
return (*IpfsDHT)(nn)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (nn *netNotifiee) Connected(n inet.Network, v inet.Conn) {
|
|
|
|
dht := nn.DHT()
|
|
|
|
select {
|
|
|
|
case <-dht.Closing():
|
|
|
|
return
|
|
|
|
}
|
|
|
|
dht.Update(dht.Context(), v.RemotePeer())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (nn *netNotifiee) Disconnected(n inet.Network, v inet.Conn) {
|
|
|
|
dht := nn.DHT()
|
|
|
|
select {
|
|
|
|
case <-dht.Closing():
|
|
|
|
return
|
|
|
|
}
|
|
|
|
dht.routingTable.Remove(v.RemotePeer())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (nn *netNotifiee) OpenedStream(n inet.Network, v inet.Stream) {}
|
|
|
|
func (nn *netNotifiee) ClosedStream(n inet.Network, v inet.Stream) {}
|
2015-01-30 20:17:55 -08:00
|
|
|
func (nn *netNotifiee) Listen(n inet.Network, a ma.Multiaddr) {}
|
|
|
|
func (nn *netNotifiee) ListenClose(n inet.Network, a ma.Multiaddr) {}
|