added wipe failover cases and ceased node update on metrics update

This commit is contained in:
0xdcarns
2022-09-28 16:17:49 -04:00
parent 4f7583e2ec
commit eb75a6829c
6 changed files with 67 additions and 29 deletions

View File

@@ -92,3 +92,30 @@ func WipeFailover(nodeid string) error {
}
return nil
}
// WipeAffectedFailoversOnly - wipes failovers for nodes that have given node (ID)
// in their respective failover lists
func WipeAffectedFailoversOnly(nodeid, network string) error {
currentNetworkNodes, err := logic.GetNetworkNodes(network)
if err != nil {
return nil
}
for i := range currentNetworkNodes {
currNodeID := currentNetworkNodes[i].ID
if currNodeID == nodeid {
WipeFailover(nodeid)
continue
}
currMetrics, err := logic.GetMetrics(currNodeID)
if err != nil || currMetrics == nil {
continue
}
if currMetrics.FailoverPeers != nil {
if len(currMetrics.FailoverPeers[nodeid]) > 0 {
WipeFailover(currNodeID)
}
}
}
return nil
}