all: remove unecessary uses of `exec`. refactor. main.js: add RAM reservation logic. lib_ram.js: renamed to lib_ram_server.js. README.js: update.
[?]
Apr 27, 2020, 1:55 PM
Y5OWMCQRLGQ56HMM53HR6CVZEMAHOEKDYMFLBDEQOJ4HLUJL7HUACDependencies
- [2]
44JNP7VZfix schedule making and running logic. - [3]
V4DMWF25remove redundant preparation steps in "hacker.js". - [4]
SLSWBNYTadded ram utilisation logic to `ram.js` and `servers.js`. split and refactored redundant code into separate library files. - [5]
HLC2L3NJadd "tor.js" and "programs.js". use `minimist` for "main.js" argument parsing. - [6]
AXGQ7FMLsplit and refactor hacking logic to "hacker.js" and argument parsing and script execution logic to "main.js". update "README.md". - [7]
NQ22FUSWadd more options to `main.js`. update `README.md`. - [8]
2BKHJI2Sinit - [9]
3NFCZ6IPfixed the ram utilisation logic. added flags to `main.js` that can prevent the execution of helpers. - [10]
RWMZ7DVLsplit and refactor various logics. update "README.md". - [11]
FA3U4WUJmore `README.md` changes. - [12]
YXH7ERRNfixed bug that prevented helper scripts running if the "home" server does not have RAM bigger than the rest of the rooted servers. - [13]
NC66CZ5Jrename certain variables that had the same names as ns functions to prevent the RAM checker from triggering.
Change contents
- replacement in sbin/servers.js at line 6
from "lib_ram.js";from "lib_ram_server.js"; - replacement in sbin/ram.js at line 5
from "lib_ram.js";from "lib_ram_server.js"; - replacement in sbin/hacker.js at line 16
from "lib_ram.js";from "lib_ram_server.js";import {boolean_can_server_run_script_threads}from "lib_ram_script.js"; - replacement in sbin/hacker.js at line 30
integer_time_finishes = await void_runner(ns, ...array_arguments.slice(1)) + Date.now();integer_time_finishes = void_runner(ns, ...array_arguments.slice(1)) + Date.now(); - edit in sbin/hacker.js at line 443
}};const boolean_can_server_run_script_threads = function(ns, float_server_used_ram_free, float_script_ram, integer_threads) {if (float_script_ram * integer_threads > float_server_used_ram_free) {return false;}else {return true; - replacement in sbin/hacker.js at line 514
if (boolean_can_server_run_script_threads(ns, float_server_used_ram_free_current, ns.getScriptRam(string_weaken), 1)) {if (boolean_can_server_run_script_threads(ns, float_server_used_ram_free_current, string_weaken, 1)) { - replacement in sbin/hacker.js at line 534
if (!boolean_can_server_run_script_threads(ns, float_server_used_ram_free_current, ns.getScriptRam(string_weaken), 1)) {if (!boolean_can_server_run_script_threads(ns, float_server_used_ram_free_current, string_weaken, 1)) { - replacement in sbin/hacker.js at line 567
if (!boolean_can_server_run_script_threads(ns, float_server_used_ram_free_current, ns.getScriptRam(string_grow), 1)) {if (!boolean_can_server_run_script_threads(ns, float_server_used_ram_free_current, string_grow, 1)) { - replacement in sbin/hacker.js at line 607
if (!boolean_can_server_run_script_threads(ns, float_server_used_ram_free_current, ns.getScriptRam(string_hack), 1)) {if (!boolean_can_server_run_script_threads(ns, float_server_used_ram_free_current, string_hack, 1)) { - replacement in sbin/hacker.js at line 685
const void_schedule_runner = async function(ns, array_schedule) {const void_schedule_runner = function(ns, array_schedule) { - replacement in sbin/hacker.js at line 709
await ns.exec(string_script, string_server_used, integer_threads, string_server_used, string_server_target, float_delay, identifier);ns.exec(string_script, string_server_used, integer_threads, string_server_used, string_server_target, float_delay, identifier); - replacement in sbin/hacker.js at line 714
const void_runner = async function(ns, integer_job_cap, float_precision, float_steal_cap, float_padding_seconds, string_server_target_argument) {const void_runner = function(ns, integer_job_cap, float_precision, float_steal_cap, float_padding_seconds, string_server_target_argument) { - replacement in sbin/hacker.js at line 721
await void_schedule_runner(ns, array_schedule);void_schedule_runner(ns, array_schedule); - file deletion: lib_ram.js
// lib_ram.js - 2GBimport {array_get_servers_rooted}from "lib_root.js";// returns the total ram of a serverexport const float_get_server_ram_total = function(ns, string_server) {return (ns.getServerRam(string_server))[0];};// returns the used ram of a serverconst float_get_server_ram_used = function(ns, string_server) {return (ns.getServerRam(string_server))[1];};// returns the amount of free ram of a serverexport const float_get_server_ram_free = function(ns, string_server) {return float_get_server_ram_total(ns, string_server) - float_get_server_ram_used(ns, string_server);};// returns the total RAM from all the servers you have root access toconst float_get_network_ram_total = function (ns) {const array_servers_rooted = array_get_servers_rooted(ns);let float_network_ram_total = 0;for (let integer_indices_0 = 0; integer_indices_0 < array_servers_rooted.length; ++integer_indices_0) {float_network_ram_total += float_get_server_ram_total(ns, array_servers_rooted[integer_indices_0]);}return float_network_ram_total;};const array_servers_rooted = array_get_servers_rooted(ns);for (let integer_indices_0 = 0; integer_indices_0 < array_servers_rooted.length; ++integer_indices_0) {}};// returns the RAM utilisation of the botnet as a decimalexport const float_get_network_ram_utilisation = function (ns) {return float_get_network_ram_used(ns) / float_get_network_ram_total(ns);};// sort an array of servers by their amounts of RAM, from lowest to highestconst void_sort_by_server_ram = function(ns, array_servers) {return array_servers.sort((string_element_0, string_element_1) => (float_get_server_ram_total(ns, string_element_0) - float_get_server_ram_total(ns, string_element_1)));};export const array_get_servers_rooted_sorted_by_ram = function(ns) {let array_servers_rooted = array_get_servers_rooted(ns);void_sort_by_server_ram(ns, array_servers_rooted);return array_servers_rooted;};return float_network_ram_used;float_network_ram_used += float_get_server_ram_used(ns, array_servers_rooted[integer_indices_0]);let float_network_ram_used = 0;// returns the total RAM used from all the servers you have root access toconst float_get_network_ram_used = function (ns) { - replacement in lib/lib_servers.js at line 4
export const array_get_servers = function(ns) {const string_host = ns.getHostname();const array_servers = [string_host];for (let integer_indices_0 = 0; integer_indices_0 < array_servers.length; ++integer_indices_0) {export const array_get_servers = function (ns) {const string_host = ns.getHostname(),array_servers = [string_host];for (let integer_indices_0 = 0;integer_indices_0 < array_servers.length;++integer_indices_0) { - replacement in lib/lib_servers.js at line 13
for (let integer_indices_1 = 0; integer_indices_1 < array_scan_results.length; ++integer_indices_1) {if (array_servers.indexOf(array_scan_results[integer_indices_1]) === -1) {for (let integer_indices_1 = 0;integer_indices_1 < array_scan_results.length;++integer_indices_1)-1 === array_servers.indexOf(array_scan_results[integer_indices_1]) && - edit in lib/lib_servers.js at line 20
}} - replacement in lib/lib_root.js at line 8
export const array_get_servers_rooted = function(ns) {const array_servers = array_get_servers(ns);const array_servers_rooted = [];for (let integer_indices_0 = 0; integer_indices_0 < array_servers.length; ++integer_indices_0) {if (ns.hasRootAccess(array_servers[integer_indices_0])) {export const array_get_servers_rooted = function (ns) {const array_servers = array_get_servers(ns),array_servers_rooted = [];for (let integer_indices_0 = 0;integer_indices_0 < array_servers.length;++integer_indices_0)ns.hasRootAccess(array_servers[integer_indices_0]) && - edit in lib/lib_root.js at line 18
}} - replacement in lib/lib_root.js at line 22
export const array_get_servers_unrooted = function(ns) {const array_servers = array_get_servers(ns);const array_servers_unrooted = [];for (let integer_indices_0 = 0; integer_indices_0 < array_servers.length; ++integer_indices_0) {if (!ns.hasRootAccess(array_servers[integer_indices_0])) {export const array_get_servers_unrooted = function (ns) {const array_servers = array_get_servers(ns),array_servers_unrooted = [];for (let integer_indices_0 = 0;integer_indices_0 < array_servers.length;++integer_indices_0)ns.hasRootAccess(array_servers[integer_indices_0]) || - edit in lib/lib_root.js at line 32
}} - replacement in lib/lib_ls.js at line 3
export const array_get_files_to_copy = function(ns, string_server_source, string_substring) {export const array_get_files_to_copy = function (ns,string_server_source,string_substring) { - replacement in lib/lib_ls.js at line 10
for (let integer_indices_0 = 0; integer_indices_0 < array_files_in_server.length; ++integer_indices_0) {for (let integer_indices_0 = 0;integer_indices_0 < array_files_in_server.length;++integer_indices_0) { - replacement in lib/lib_ls.js at line 16
if (string_file.includes(string_substring)) {string_file.includes(string_substring) && - edit in lib/lib_ls.js at line 18
} - replacement in bin/killall.js at line 1
// killall.js - 3.05GB - TODO: implement a loop that repeats logic until all appropriate scripts have actually been killed.// killall.js - 3.05GB - TODO:// * implement a loop that repeats logic until all appropriate scripts have actually been killed.// * use kill instead of scriptKill. maybe separate that into a lib file that main.js will also use. - replacement in README.md at line 10
### "main.js" (8.05 GB)### "main.js" (6.9 GB)* Reserve at least enough RAM to be able to run "hacker.js" (8.05 GB). - replacement in README.md at line 19
* Kill itself by spawning "hacker.js" (8.05 GB) which should then:* Kill itself by spawning "hacker.js" which should then: - replacement in README.md at line 71
* Prevents the "servers.js" script from being started which is responsible for the purchasing and replacement of servers.* Prevents the "servers.js" script from being started which is responsible for buying and replacing bought servers. - replacement in README.md at line 79
* Prevents the "tor.js" script from being started which is responsible for buyinh a TOR Router.* Prevents the "tor.js" script from being started which is responsible for buying a TOR Router.