adding comments

This commit is contained in:
afeiszli
2022-02-06 11:43:07 -05:00
parent 7c56420b9f
commit 62d0a6a83a
2 changed files with 5 additions and 2 deletions

View File

@@ -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

View File

@@ -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 {