added force

This commit is contained in:
0xdcarns 2022-02-17 09:33:30 -05:00
parent 1e56ecfdb9
commit 49e0545274

View file

@ -107,12 +107,7 @@ func (s *NodeServiceServer) CreateNode(ctx context.Context, req *nodepb.Object)
Type: nodepb.NODE_TYPE,
}
var currentServerNode, getErr = logic.GetNetworkServerLeader(node.Network)
if getErr == nil {
if err := logic.ServerUpdate(&currentServerNode, false); err != nil {
logger.Log(1, "server node:", currentServerNode.ID, "failed update")
}
}
runForceServerUpdate(&node)
go func(node *models.Node) {
if node.UDPHolePunch == "yes" {
@ -221,7 +216,7 @@ func (s *NodeServiceServer) DeleteNode(ctx context.Context, req *nodepb.Object)
return nil, err
}
runUpdates(&node, false)
runForceServerUpdate(&node)
return &nodepb.Object{
Data: "success",
@ -313,3 +308,12 @@ func getNodeFromRequestData(data string) (models.Node, error) {
func isServer(node *models.Node) bool {
return node.IsServer == "yes"
}
func runForceServerUpdate(node *models.Node) {
var currentServerNode, getErr = logic.GetNetworkServerLeader(node.Network)
if getErr == nil {
if err := logic.ServerUpdate(&currentServerNode, false); err != nil {
logger.Log(1, "server node:", currentServerNode.ID, "failed update")
}
}
}