Explorar o código

leave comms automatically if last network

afeiszli %!s(int64=3) %!d(string=hai) anos
pai
achega
f5c8f6ed22
Modificáronse 1 ficheiros con 7 adicións e 0 borrados
  1. 7 0
      netclient/command/commands.go

+ 7 - 0
netclient/command/commands.go

@@ -95,6 +95,13 @@ func Leave(cfg config.ClientConfig, force bool) error {
 	} else {
 		ncutils.PrintLog("success", 0)
 	}
+	nets, err := ncutils.GetSystemNetworks()
+	if err == nil && len(nets) == 1 {
+		if nets[0] == cfg.Node.CommID {
+			ncutils.PrintLog("detected comms as remaining network, removing...", 1)
+			err = functions.LeaveNetwork(nets[0], true)
+		}
+	}
 	return err
 }