func (s *StateStore) UpdateNodeStatus(index uint64, nodeID, status string) error {
	txn := s.db.Txn(true)
	defer txn.Abort()

	// Lookup the node
	existing, err := txn.First("nodes", "id", nodeID)
	if err != nil {
		return fmt.Errorf("node lookup failed: %v", err)
	}
	if existing == nil {
		return fmt.Errorf("node not found")
	}

	// Copy the existing node
	existingNode := existing.(*structs.Node)
	copyNode := new(structs.Node)
	*copyNode = *existingNode

	// Update the status in the copy
	copyNode.Status = status
	copyNode.ModifyIndex = index

	// Insert the node
	if err := txn.Insert("nodes", copyNode); err != nil {
		return fmt.Errorf("node update failed: %v", err)
	}
	if err := txn.Insert("index", &IndexEntry{"nodes", index}); err != nil {
		return fmt.Errorf("index update failed: %v", err)
	}

	txn.Commit()
	return nil
}
// UpdateNodeStatus is used to update the status of a node
UpdateNodeStatus is used to update the status of a node
// UpdateNodeStatus is used to update the status of a node
func (s *StateStore) UpdateNodeStatus(index uint64, nodeID, status string) error {
	txn := s.db.Txn(true)
	defer txn.Abort()
	existing, err := txn.First("nodes", "id", nodeID)
	if err != nil {
		return fmt.Errorf("node lookup failed: %v", err)
	}
	if existing == nil {
		return fmt.Errorf("node not found")
	}
	existingNode := existing.(*structs.Node)
	copyNode := new(structs.Node)
	*copyNode = *existingNode
	copyNode.Status = status
	copyNode.ModifyIndex = index
	if err := txn.Insert("nodes", copyNode); err != nil {
		return fmt.Errorf("node update failed: %v", err)
	}
	if err := txn.Insert("index", &IndexEntry{"nodes", index}); err != nil {
		return fmt.Errorf("index update failed: %v", err)
	}
	txn.Commit()
	return nil
}
func ( s * StateStore ) UpdateNodeStatus ( index uint64 , nodeID , status string ) error { txn := s . db . Txn ( true ) defer txn . Abort ( ) existing , err := txn . First ( " " , " " , nodeID ) if err != nil { return fmt . Errorf ( " " , err ) } if existing == nil { return fmt . Errorf ( " " ) } existingNode := existing . ( * structs . Node ) copyNode := new ( structs . Node ) * copyNode = * existingNode copyNode . Status = status copyNode . ModifyIndex = index if err := txn . Insert ( " " , copyNode ) ; err != nil { return fmt . Errorf ( " " , err ) } if err := txn . Insert ( " " , & IndexEntry { " " , index } ) ; err != nil { return fmt . Errorf ( " " , err ) } txn . Commit ( ) return nil }
UpdateNodeStatus is used to update the status of a node
UpdateNodeStatus is used to update the status of a node
// Lookup the node // Copy the existing node // Update the status in the copy // Insert the node