Updated log and comments

This commit is contained in:
Milos Gajdos 2020-01-13 20:07:10 +00:00
parent efcac3d009
commit b4261e8cf9
No known key found for this signature in database
GPG Key ID: 8B31058CC55DFD4F

View File

@ -337,7 +337,7 @@ func (n *network) advertise(advertChan <-chan *router.Advert) {
for i := 0; i < max; i++ { for i := 0; i < max; i++ {
if peer := n.node.GetPeerNode(peers[rnd.Intn(len(peers))].Id()); peer != nil { if peer := n.node.GetPeerNode(peers[rnd.Intn(len(peers))].Id()); peer != nil {
if err := n.sendTo("advert", ControlChannel, peer, msg); err != nil { if err := n.sendTo("advert", ControlChannel, peer, msg); err != nil {
log.Debugf("Network failed to advertise routes: %v", err) log.Debugf("Network failed to advertise routes to %s: %v", peer.Id(), err)
} }
} }
} }
@ -359,7 +359,7 @@ func (n *network) advertise(advertChan <-chan *router.Advert) {
log.Debugf("Network failed to advertise routes to %s: %v, sending multicast", peer.Id(), err) log.Debugf("Network failed to advertise routes to %s: %v, sending multicast", peer.Id(), err)
// send a multicast message if we fail to send Unicast message // send a multicast message if we fail to send Unicast message
if err := n.sendMsg("advert", ControlChannel, msg); err != nil { if err := n.sendMsg("advert", ControlChannel, msg); err != nil {
log.Debugf("Network failed to advertise routes: %v", err) log.Debugf("Network failed to advertise routes to %s: %v", peer.Id(), err)
} }
} }
} }
@ -516,10 +516,11 @@ func (n *network) handleCtrlConn(s tunnel.Session, msg chan *message) {
} }
// getHopCount queries network graph and returns hop count for given router // getHopCount queries network graph and returns hop count for given router
// NOTE: this should be called getHopeMetric
// - Routes for local services have hop count 1 // - Routes for local services have hop count 1
// - Routes with ID of adjacent nodes have hop count 2 // - Routes with ID of adjacent nodes have hop count 10
// - Routes by peers of the advertiser have hop count 3 // - Routes by peers of the advertiser have hop count 100
// - Routes beyond node neighbourhood have hop count 4 // - Routes beyond node neighbourhood have hop count 1000
func (n *network) getHopCount(rtr string) int { func (n *network) getHopCount(rtr string) int {
// make sure node.peers are not modified // make sure node.peers are not modified
n.node.RLock() n.node.RLock()
@ -1207,7 +1208,7 @@ func (n *network) manage() {
// unknown link and peer so lets do the connect flow // unknown link and peer so lets do the connect flow
if err := n.sendTo("connect", NetworkChannel, peer, msg); err != nil { if err := n.sendTo("connect", NetworkChannel, peer, msg); err != nil {
log.Debugf("Network failed to advertise peer %s: %v", peer.id, err) log.Debugf("Network failed to connect %s: %v", peer.id, err)
continue continue
} }