Skip to content

Commit

Permalink
feat(torch): comment code - rename var
Browse files Browse the repository at this point in the history
Signed-off-by: Jose Ramon Mañes <[email protected]>
  • Loading branch information
tty47 committed Oct 25, 2023
1 parent 1b5054a commit 55d3657
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pkg/nodes/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,27 @@ func processQueue() {
}
}

// CheckNodesInDBOrCreateThem try to find the node in the DB, if the node is not in the DB, it tries to create it.
func CheckNodesInDBOrCreateThem(peer config.Peer, red *redis.RedisClient, ctx context.Context) {
log.Info("Processing Node in the queue: ", "[", peer.NodeName, "]")
// check if the node is in the DB
c, err := redis.CheckIfNodeExistsInDB(red, ctx, peer.NodeName)
ma, err := redis.CheckIfNodeExistsInDB(red, ctx, peer.NodeName)
if err != nil {
log.Error("Error CheckIfNodeExistsInDB for node: [", peer.NodeName, "]", err)
}

// if the node doesn't exist in the DB, let's try to create it
if c == "" {
if ma == "" {
log.Info("Node ", "["+peer.NodeName+"]"+" NOT found in DB, let's try to generate it")
c, err = GenerateNodeIdAndSaveIt(peer, peer.NodeName, red, ctx)
ma, err = GenerateNodeIdAndSaveIt(peer, peer.NodeName, red, ctx)
if err != nil {
log.Error("Error GenerateNodeIdAndSaveIt for full-node: [", peer.NodeName, "]", err)
}
}
if c == "" {

// check if the multiaddress is empty after trying to generate it
if ma == "" {
// check if the node is still under the maximum number of retries
if peer.RetryCount < MaxRetryCount {
log.Info("Node ", "["+peer.NodeName+"]"+" NOT found in DB, adding it to the queue, attempt: ", "[", peer.RetryCount, "]")
peer.RetryCount++ // increment the counter
Expand All @@ -70,12 +75,12 @@ func CheckNodesInDBOrCreateThem(peer config.Peer, red *redis.RedisClient, ctx co
log.Info("Max retry count reached for node: ", "[", peer.NodeName, "]", "it might have some issues...")
}
} else {
log.Info("Node ", "[", peer.NodeName, "]", " found in DB, ID: ", "[", c, "]")
log.Info("Node ", "[", peer.NodeName, "]", " found in DB, ID: ", "[", ma, "]")
// Register a multi-address metric
m := metrics.MultiAddrs{
ServiceName: "torch",
NodeName: peer.NodeName,
MultiAddr: c,
MultiAddr: ma,
Namespace: k8s.GetCurrentNamespace(),
Value: 1,
}
Expand Down

0 comments on commit 55d3657

Please sign in to comment.