fix a few things about getRecentScritps

This commit is contained in:
Olivier Gagnon
2022-04-12 14:45:48 -04:00
parent a9b03f34ab
commit 52e01fc026
7 changed files with 16 additions and 30 deletions
+2 -1
View File
@@ -15,6 +15,7 @@ export const RamCostConstants: IMap<number> = {
ScriptWeakenRamCost: 0.15,
ScriptWeakenAnalyzeRamCost: 1,
ScriptScanRamCost: 0.2,
ScriptRecentScriptsRamCost: 0.2,
ScriptPortProgramRamCost: 0.05,
ScriptRunRamCost: 1.0,
ScriptExecRamCost: 1.3,
@@ -140,7 +141,7 @@ export const RamCosts: IMap<any> = {
scp: RamCostConstants.ScriptScpRamCost,
ls: RamCostConstants.ScriptScanRamCost,
ps: RamCostConstants.ScriptScanRamCost,
getRecentScripts: RamCostConstants.ScriptScanRamCost,
getRecentScripts: RamCostConstants.ScriptRecentScriptsRamCost,
hasRootAccess: RamCostConstants.ScriptHasRootAccessRamCost,
getIp: RamCostConstants.ScriptGetHostnameRamCost,
getHostname: RamCostConstants.ScriptGetHostnameRamCost,
+3 -11
View File
@@ -5,15 +5,11 @@ import { WorkerScript } from "./WorkerScript";
export const recentScripts: RecentScript[] = [];
export function AddRecentScript(workerScript: WorkerScript): void {
if (recentScripts.find((r) => r.pid === workerScript.pid)) return;
if (recentScripts.find((r) => r.runningScript.pid === workerScript.pid)) return;
const killedTime = new Date();
recentScripts.unshift({
filename: workerScript.name,
args: workerScript.args,
pid: workerScript.pid,
timestamp: killedTime,
timestampEpoch: killedTime.getTime(),
timeOfDeath: killedTime,
runningScript: workerScript.scriptRef,
});
@@ -23,10 +19,6 @@ export function AddRecentScript(workerScript: WorkerScript): void {
}
export interface RecentScript {
filename: string;
args: string[];
pid: number;
timestamp: Date;
timestampEpoch: number;
timeOfDeath: Date;
runningScript: RunningScript;
}