Browse Source

adding comments

afeiszli 3 years ago
parent
commit
62d0a6a83a
2 changed files with 5 additions and 2 deletions
  1. 3 2
      logic/nodes.go
  2. 2 0
      logic/relay.go

+ 3 - 2
logic/nodes.go

@@ -19,7 +19,8 @@ import (
 	"golang.org/x/crypto/bcrypt"
 	"golang.org/x/crypto/bcrypt"
 )
 )
 
 
-const RELAY_NODE_ERR = "could not find relay for node "
+// RELAY_NODE_ERR - error to return if relay node is unfound
+const RELAY_NODE_ERR = "could not find relay for node"
 
 
 // GetNetworkNodes - gets the nodes of a network
 // GetNetworkNodes - gets the nodes of a network
 func GetNetworkNodes(network string) ([]models.Node, error) {
 func GetNetworkNodes(network string) ([]models.Node, error) {
@@ -508,7 +509,7 @@ func GetNodeRelay(network string, relayedNodeAddr string) (models.Node, error) {
 			}
 			}
 		}
 		}
 	}
 	}
-	return relay, errors.New(RELAY_NODE_ERR + relayedNodeAddr)
+	return relay, errors.New(RELAY_NODE_ERR + " " + relayedNodeAddr)
 }
 }
 
 
 // GetNodeByIDorMacAddress - gets the node, if a mac address exists, but not id, then it should delete it and recreate in DB with new ID
 // GetNodeByIDorMacAddress - gets the node, if a mac address exists, but not id, then it should delete it and recreate in DB with new ID

+ 2 - 0
logic/relay.go

@@ -84,6 +84,7 @@ func SetRelayedNodes(yesOrno string, networkName string, addrs []string) error {
 	return nil
 	return nil
 }
 }
 
 
+// SetNodeIsRelayed - Sets IsRelayed to on or off for relay
 func SetNodeIsRelayed(yesOrno string, id string) error {
 func SetNodeIsRelayed(yesOrno string, id string) error {
 	node, err := GetNodeByID(id)
 	node, err := GetNodeByID(id)
 	if err != nil {
 	if err != nil {
@@ -106,6 +107,7 @@ func SetNodeIsRelayed(yesOrno string, id string) error {
 	return database.Insert(node.ID, string(data), database.NODES_TABLE_NAME)
 	return database.Insert(node.ID, string(data), database.NODES_TABLE_NAME)
 }
 }
 
 
+// PeerListUnRelay - call this function if a relayed node fails to get its relay: unrelays node and gets new peer list
 func PeerListUnRelay(id string, network string) ([]models.Node, error) {
 func PeerListUnRelay(id string, network string) ([]models.Node, error) {
 	err := SetNodeIsRelayed("no", id)
 	err := SetNodeIsRelayed("no", id)
 	if err != nil {
 	if err != nil {