@nosana/node 1.1.98 → 1.1.99-rc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { logEmitter } from '../../../../packages/common/src/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { classifyPhase } from './classifyState.js';
|
|
3
3
|
export const state = (() => {
|
|
4
4
|
let instance = null;
|
|
5
5
|
return (node) => {
|
|
@@ -38,7 +38,7 @@ export class NodeState {
|
|
|
38
38
|
getNodeInfo() {
|
|
39
39
|
return {
|
|
40
40
|
...this.info,
|
|
41
|
-
state:
|
|
41
|
+
state: classifyPhase(this.history.map((h) => h.status)),
|
|
42
42
|
status: this.status,
|
|
43
43
|
details: this.state,
|
|
44
44
|
since: new Date(this.since).toISOString(),
|
|
@@ -346,6 +346,22 @@ export class NodeState {
|
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
|
+
if (data.method == 'fetchMarketResources') {
|
|
350
|
+
const market = `${data.arguments[0]?.address ?? ''}`;
|
|
351
|
+
if (data.type == 'call') {
|
|
352
|
+
this.addState('downloading-market-resources', { node: this.shared.node, market });
|
|
353
|
+
}
|
|
354
|
+
if (data.type == 'error') {
|
|
355
|
+
this.addState('downloading-market-resources-failed', {
|
|
356
|
+
node: this.shared.node,
|
|
357
|
+
market,
|
|
358
|
+
error: `${data.error}`,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
if (data.type == 'return') {
|
|
362
|
+
this.addState('downloading-market-resources-success', { node: this.shared.node, market });
|
|
363
|
+
}
|
|
364
|
+
}
|
|
349
365
|
if (data.method == 'queue') {
|
|
350
366
|
const market = data.arguments[0];
|
|
351
367
|
this.shared.market = market;
|
|
@@ -6,6 +6,7 @@ export declare enum StateCategory {
|
|
|
6
6
|
STARTING = "STARTING",
|
|
7
7
|
WAITING_FOR_SOL = "WAITING_FOR_SOL",
|
|
8
8
|
WAITING_FOR_REGISTRATION = "WAITING_FOR_REGISTRATION",
|
|
9
|
+
DOWNLOADING_RESOURCES = "DOWNLOADING_RESOURCES",
|
|
9
10
|
JOINING_MARKET = "JOINING_MARKET",
|
|
10
11
|
QUEUED = "QUEUED",
|
|
11
12
|
OTHER = "OTHER"
|
|
@@ -14,3 +15,5 @@ export declare const stateClassificationMap: {
|
|
|
14
15
|
[key: string]: StateCategory;
|
|
15
16
|
};
|
|
16
17
|
export declare function classifyState(status: string): StateCategory;
|
|
18
|
+
/** The category of the latest status that is not a step, newest last; OTHER without one. */
|
|
19
|
+
export declare function classifyPhase(statuses: string[]): StateCategory;
|
|
@@ -7,6 +7,7 @@ export var StateCategory;
|
|
|
7
7
|
StateCategory["STARTING"] = "STARTING";
|
|
8
8
|
StateCategory["WAITING_FOR_SOL"] = "WAITING_FOR_SOL";
|
|
9
9
|
StateCategory["WAITING_FOR_REGISTRATION"] = "WAITING_FOR_REGISTRATION";
|
|
10
|
+
StateCategory["DOWNLOADING_RESOURCES"] = "DOWNLOADING_RESOURCES";
|
|
10
11
|
StateCategory["JOINING_MARKET"] = "JOINING_MARKET";
|
|
11
12
|
StateCategory["QUEUED"] = "QUEUED";
|
|
12
13
|
StateCategory["OTHER"] = "OTHER";
|
|
@@ -33,6 +34,7 @@ export const stateClassificationMap = {
|
|
|
33
34
|
'benchmark-running': StateCategory.BENCHMARKING,
|
|
34
35
|
'benchmark-passed': StateCategory.BENCHMARKING,
|
|
35
36
|
'benchmark-failed': StateCategory.BENCHMARKING,
|
|
37
|
+
'benchmark-error': StateCategory.BENCHMARKING,
|
|
36
38
|
// HEALTHCHECK states
|
|
37
39
|
'health-check-running': StateCategory.HEALTHCHECK,
|
|
38
40
|
'health-check-failed': StateCategory.HEALTHCHECK,
|
|
@@ -49,6 +51,10 @@ export const stateClassificationMap = {
|
|
|
49
51
|
'waiting-for-sol': StateCategory.WAITING_FOR_SOL,
|
|
50
52
|
'waiting-for-registration': StateCategory.WAITING_FOR_REGISTRATION,
|
|
51
53
|
'registration-failed': StateCategory.WAITING_FOR_REGISTRATION,
|
|
54
|
+
// The market's images and resources, fetched before the node joins it
|
|
55
|
+
'downloading-market-resources': StateCategory.DOWNLOADING_RESOURCES,
|
|
56
|
+
'downloading-market-resources-success': StateCategory.DOWNLOADING_RESOURCES,
|
|
57
|
+
'downloading-market-resources-failed': StateCategory.DOWNLOADING_RESOURCES,
|
|
52
58
|
// JOINING MARKET states
|
|
53
59
|
'queueing-in-market': StateCategory.JOINING_MARKET,
|
|
54
60
|
'queueing-in-market-success': StateCategory.QUEUED,
|
|
@@ -63,3 +69,16 @@ export const stateClassificationMap = {
|
|
|
63
69
|
export function classifyState(status) {
|
|
64
70
|
return stateClassificationMap[status] || StateCategory.OTHER;
|
|
65
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* The steps a phase (a benchmark, a health check, a job, the market's resources) is made of: they
|
|
74
|
+
* say what the node does within it, not that it left it.
|
|
75
|
+
*/
|
|
76
|
+
const STEP = /^(pulling-image|creating-network|deleting-network|running-container|stopping-container|running-operation|stop-operation)(-success|-failed)?$/;
|
|
77
|
+
/** The category of the latest status that is not a step, newest last; OTHER without one. */
|
|
78
|
+
export function classifyPhase(statuses) {
|
|
79
|
+
for (let i = statuses.length - 1; i >= 0; i--) {
|
|
80
|
+
if (!STEP.test(statuses[i]))
|
|
81
|
+
return classifyState(statuses[i]);
|
|
82
|
+
}
|
|
83
|
+
return StateCategory.OTHER;
|
|
84
|
+
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nosana/node",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.99-rc",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@nosana/node",
|
|
9
|
-
"version": "1.1.
|
|
9
|
+
"version": "1.1.99-rc",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"workspaces": [
|
|
12
12
|
"packages/*"
|