servers.js: fix and refactor.

[?]
Apr 27, 2020, 11:55 PM
3TZILRX2OJIN4CH4P5MZ2PB56CJAPTDXGSU46FOTECHLQQBCPMNQC

Dependencies

  • [2] HSNSECD5 all: refactor. main.js: fix call to `void_kill_script_named_server_named`.
  • [3] 2BKHJI2S init
  • [4] SLSWBNYT added ram utilisation logic to `ram.js` and `servers.js`. split and refactored redundant code into separate library files.
  • [5] Y5OWMCQR 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.

Change contents

  • replacement in sbin/servers.js at line 4
    [3.309][3.309:340](),[3.340][3.6:32]()
    float_get_server_ram_total
    }
    from "lib_ram_server.js";
    [3.309]
    [3.359]
    float_get_server_ram_total,
    } from "lib_ram_server.js";
  • replacement in sbin/servers.js at line 7
    [3.360][3.2650:2739](),[3.2650][3.2650:2739](),[3.2739][3.361:464]()
    export const main = async function(ns) {
    const float_period_check = ns.args[0] * 1000;
    const string_servers_bought_name = ns.args[1];
    const float_ram_utilisation_threshold = ns.args[2];
    [3.360]
    [3.3412]
    export const main = async function (ns) {
    const float_period_check = 1e3 * ns.args[0],
    string_servers_bought_name = ns.args[1],
    float_ram_utilisation_threshold = ns.args[2];
    for (; !boolean_servers_bought_all_max(ns); ) {
    for (
    ;
    float_get_network_ram_utilisation(ns) > float_ram_utilisation_threshold;
  • replacement in sbin/servers.js at line 16
    [3.3413][3.465:825](),[3.825][3.3966:3974](),[3.3966][3.3966:3974](),[3.3974][3.826:847]()
    while (!boolean_servers_bought_all_max(ns)) {
    while (float_get_network_ram_utilisation(ns) > float_ram_utilisation_threshold) {
    while (boolean_conditions_server_delete_purchase(ns)) {
    ns.deleteServer(string_get_server_bought_smallest(ns));
    ns.purchaseServer(string_servers_bought_name, integer_get_server_ram_biggest_afforded(ns));
    }
    while (
    [3.3413]
    [3.847]
    ) {
    for (; boolean_conditions_server_delete_purchase(ns); )
    ns.deleteServer(string_get_server_bought_smallest(ns)),
    ns.purchaseServer(
    string_servers_bought_name,
    integer_get_server_ram_biggest_afforded(ns)
    ),
    await ns.sleep(float_period_check);
    for (
    ;
  • replacement in sbin/servers.js at line 28
    [3.951][3.951:1110](),[3.1110][3.4773:4781](),[3.4773][3.4773:4781]()
    boolean_conditions_server_purchase_1(ns)
    ) {
    ns.purchaseServer(string_servers_bought_name, integer_get_server_ram_biggest_afforded(ns));
    }
    [3.951]
    [3.4818]
    boolean_conditions_server_purchase_1(ns);
    )
    ns.purchaseServer(
    string_servers_bought_name,
    integer_get_server_ram_biggest_afforded(ns)
    )
    await ns.sleep(float_period_check);
  • replacement in sbin/servers.js at line 44
    [2.190][2.190:220]()
    return object_constants = {
    [2.190]
    [3.1246]
    return {