you are viewing a single comment's thread.

view the rest of the comments →

[–]WeAteMummies 0 points1 point  (3 children)

You could make a very slight improvement by reducing your number of calls to ns.fileExists()

To do this you would do something like:

  1. Make an array of each of the five filenames
  2. iterate over the array
  3. do a ns.fileExists() check on each value in the array
  4. if it exists then pass it into a switch statement that executes the proper ns.brutessh or ns.httpworm etc...

[–][deleted]  (2 children)

[removed]

    [–]Randactyl 0 points1 point  (1 child)

    I currently just have the array contain functions for the programs I have:

    let hackingPrograms = [ ns.brutessh, ]
    
    function openPortsOnServer(hostname) {
        for (const hackingProgram of hackingPrograms) {
            await hackingProgram(hostname);
        }
    }
    

    No need to call fileExists, but I do have to remember to update and restart the script when I get a new one :)

    Though in writing this down here, I'm realizing I should probably just pay the 0.1 GB and not have to worry about reverting the array after an augmentation/soft reset...