Fixed typos and simplified map iteration
This commit is contained in:
parent
ec354934e3
commit
dddfb6f878
@ -377,7 +377,7 @@ func (n *network) processNetChan(client transport.Client, listener tunnel.Listen
|
|||||||
}
|
}
|
||||||
n.Unlock()
|
n.Unlock()
|
||||||
// send a solicit message when discovering a new node
|
// send a solicit message when discovering a new node
|
||||||
// NOTE: we need to send the solicit message here after the Lock is released as sendMsg locs
|
// NOTE: we need to send the solicit message here after the Lock is released as sendMsg locks, too
|
||||||
if !exists {
|
if !exists {
|
||||||
if err := n.sendMsg("solicit", NetworkChannel); err != nil {
|
if err := n.sendMsg("solicit", NetworkChannel); err != nil {
|
||||||
log.Debugf("Network failed to send solicit message: %s", err)
|
log.Debugf("Network failed to send solicit message: %s", err)
|
||||||
@ -433,7 +433,7 @@ func (n *network) sendMsg(msgType string, channel string) error {
|
|||||||
n.RLock()
|
n.RLock()
|
||||||
nodes := make([]*pbNet.Node, len(n.neighbours))
|
nodes := make([]*pbNet.Node, len(n.neighbours))
|
||||||
i := 0
|
i := 0
|
||||||
for id, _ := range n.neighbours {
|
for id := range n.neighbours {
|
||||||
nodes[i] = &pbNet.Node{
|
nodes[i] = &pbNet.Node{
|
||||||
Id: id,
|
Id: id,
|
||||||
Address: n.neighbours[id].address,
|
Address: n.neighbours[id].address,
|
||||||
@ -609,7 +609,7 @@ func (n *network) setRouteMetric(route *router.Route) {
|
|||||||
|
|
||||||
// check if the route origin is the neighbour of our neighbour
|
// check if the route origin is the neighbour of our neighbour
|
||||||
for _, node := range n.neighbours {
|
for _, node := range n.neighbours {
|
||||||
for id, _ := range node.neighbours {
|
for id := range node.neighbours {
|
||||||
if route.Router == id {
|
if route.Router == id {
|
||||||
route.Metric = 100
|
route.Metric = 100
|
||||||
n.RUnlock()
|
n.RUnlock()
|
||||||
|
@ -28,7 +28,7 @@ type Router interface {
|
|||||||
Advertise() (<-chan *Advert, error)
|
Advertise() (<-chan *Advert, error)
|
||||||
// Process processes incoming adverts
|
// Process processes incoming adverts
|
||||||
Process(*Advert) error
|
Process(*Advert) error
|
||||||
// Solicit advertises the whole routing table ot the network
|
// Solicit advertises the whole routing table to the network
|
||||||
Solicit() error
|
Solicit() error
|
||||||
// Lookup queries routes in the routing table
|
// Lookup queries routes in the routing table
|
||||||
Lookup(Query) ([]Route, error)
|
Lookup(Query) ([]Route, error)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user