@ocap/resolver 1.30.22 → 1.30.24
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/esm/api.mjs +37 -2
- package/lib/api.cjs +37 -2
- package/package.json +14 -14
package/esm/api.mjs
CHANGED
|
@@ -54,11 +54,46 @@ function createAPIHandler({ resolver }) {
|
|
|
54
54
|
const unfinalizedAgeThresholdMs = Number(process.env.LEDGER_HEALTH_UNFINALIZED_AGE_THRESHOLD_MS) || 3e5;
|
|
55
55
|
const now = Date.now();
|
|
56
56
|
const oldestUnfinalizedAgeMs = health.oldestUnfinalizedTimestamp ? now - health.oldestUnfinalizedTimestamp : null;
|
|
57
|
-
const
|
|
57
|
+
const lagViolation = health.checkpointLag > lagThreshold;
|
|
58
|
+
const ageViolation = lagViolation && health.checkpointAgeMs != null && health.checkpointAgeMs > ageThresholdMs;
|
|
59
|
+
const unfinalizedViolation = oldestUnfinalizedAgeMs != null && oldestUnfinalizedAgeMs > unfinalizedAgeThresholdMs;
|
|
60
|
+
const healthy = !lagViolation && !ageViolation && !unfinalizedViolation;
|
|
61
|
+
const formatDuration = (ms) => {
|
|
62
|
+
if (ms == null) return null;
|
|
63
|
+
const s = Math.floor(ms / 1e3);
|
|
64
|
+
const d = Math.floor(s / 86400);
|
|
65
|
+
const h = Math.floor(s % 86400 / 3600);
|
|
66
|
+
const m = Math.floor(s % 3600 / 60);
|
|
67
|
+
const sec = s % 60;
|
|
68
|
+
const parts = [];
|
|
69
|
+
if (d) parts.push(`${d}d`);
|
|
70
|
+
if (h) parts.push(`${h}h`);
|
|
71
|
+
if (m) parts.push(`${m}m`);
|
|
72
|
+
if (sec || parts.length === 0) parts.push(`${sec}s`);
|
|
73
|
+
return parts.join(" ");
|
|
74
|
+
};
|
|
75
|
+
const toIso = (ts) => ts ? new Date(ts).toISOString() : null;
|
|
58
76
|
res.json({
|
|
59
77
|
healthy,
|
|
60
|
-
|
|
78
|
+
latestSequence: health.latestSequence,
|
|
79
|
+
latestCheckpoint: health.latestCheckpoint ? {
|
|
80
|
+
...health.latestCheckpoint,
|
|
81
|
+
timestampIso: toIso(health.latestCheckpoint.timestamp)
|
|
82
|
+
} : null,
|
|
83
|
+
checkpointLag: health.checkpointLag,
|
|
84
|
+
checkpointAgeMs: health.checkpointAgeMs,
|
|
85
|
+
checkpointAge: formatDuration(health.checkpointAgeMs),
|
|
86
|
+
unfinalizedCount: health.unfinalizedCount,
|
|
87
|
+
oldestUnfinalizedTimestamp: health.oldestUnfinalizedTimestamp,
|
|
88
|
+
oldestUnfinalizedTimestampIso: toIso(health.oldestUnfinalizedTimestamp),
|
|
61
89
|
oldestUnfinalizedAgeMs,
|
|
90
|
+
oldestUnfinalizedAge: formatDuration(oldestUnfinalizedAgeMs),
|
|
91
|
+
nowIso: new Date(now).toISOString(),
|
|
92
|
+
violations: {
|
|
93
|
+
lag: lagViolation,
|
|
94
|
+
age: ageViolation,
|
|
95
|
+
unfinalized: unfinalizedViolation
|
|
96
|
+
},
|
|
62
97
|
thresholds: {
|
|
63
98
|
checkpointLag: lagThreshold,
|
|
64
99
|
checkpointAgeMs: ageThresholdMs,
|
package/lib/api.cjs
CHANGED
|
@@ -55,11 +55,46 @@ function createAPIHandler({ resolver }) {
|
|
|
55
55
|
const unfinalizedAgeThresholdMs = Number(process.env.LEDGER_HEALTH_UNFINALIZED_AGE_THRESHOLD_MS) || 3e5;
|
|
56
56
|
const now = Date.now();
|
|
57
57
|
const oldestUnfinalizedAgeMs = health.oldestUnfinalizedTimestamp ? now - health.oldestUnfinalizedTimestamp : null;
|
|
58
|
-
const
|
|
58
|
+
const lagViolation = health.checkpointLag > lagThreshold;
|
|
59
|
+
const ageViolation = lagViolation && health.checkpointAgeMs != null && health.checkpointAgeMs > ageThresholdMs;
|
|
60
|
+
const unfinalizedViolation = oldestUnfinalizedAgeMs != null && oldestUnfinalizedAgeMs > unfinalizedAgeThresholdMs;
|
|
61
|
+
const healthy = !lagViolation && !ageViolation && !unfinalizedViolation;
|
|
62
|
+
const formatDuration = (ms) => {
|
|
63
|
+
if (ms == null) return null;
|
|
64
|
+
const s = Math.floor(ms / 1e3);
|
|
65
|
+
const d = Math.floor(s / 86400);
|
|
66
|
+
const h = Math.floor(s % 86400 / 3600);
|
|
67
|
+
const m = Math.floor(s % 3600 / 60);
|
|
68
|
+
const sec = s % 60;
|
|
69
|
+
const parts = [];
|
|
70
|
+
if (d) parts.push(`${d}d`);
|
|
71
|
+
if (h) parts.push(`${h}h`);
|
|
72
|
+
if (m) parts.push(`${m}m`);
|
|
73
|
+
if (sec || parts.length === 0) parts.push(`${sec}s`);
|
|
74
|
+
return parts.join(" ");
|
|
75
|
+
};
|
|
76
|
+
const toIso = (ts) => ts ? new Date(ts).toISOString() : null;
|
|
59
77
|
res.json({
|
|
60
78
|
healthy,
|
|
61
|
-
|
|
79
|
+
latestSequence: health.latestSequence,
|
|
80
|
+
latestCheckpoint: health.latestCheckpoint ? {
|
|
81
|
+
...health.latestCheckpoint,
|
|
82
|
+
timestampIso: toIso(health.latestCheckpoint.timestamp)
|
|
83
|
+
} : null,
|
|
84
|
+
checkpointLag: health.checkpointLag,
|
|
85
|
+
checkpointAgeMs: health.checkpointAgeMs,
|
|
86
|
+
checkpointAge: formatDuration(health.checkpointAgeMs),
|
|
87
|
+
unfinalizedCount: health.unfinalizedCount,
|
|
88
|
+
oldestUnfinalizedTimestamp: health.oldestUnfinalizedTimestamp,
|
|
89
|
+
oldestUnfinalizedTimestampIso: toIso(health.oldestUnfinalizedTimestamp),
|
|
62
90
|
oldestUnfinalizedAgeMs,
|
|
91
|
+
oldestUnfinalizedAge: formatDuration(oldestUnfinalizedAgeMs),
|
|
92
|
+
nowIso: new Date(now).toISOString(),
|
|
93
|
+
violations: {
|
|
94
|
+
lag: lagViolation,
|
|
95
|
+
age: ageViolation,
|
|
96
|
+
unfinalized: unfinalizedViolation
|
|
97
|
+
},
|
|
63
98
|
thresholds: {
|
|
64
99
|
checkpointLag: lagThreshold,
|
|
65
100
|
checkpointAgeMs: ageThresholdMs,
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.30.
|
|
6
|
+
"version": "1.30.24",
|
|
7
7
|
"description": "GraphQL resolver built upon ocap statedb and GQL layer",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./lib/index.cjs",
|
|
@@ -49,20 +49,20 @@
|
|
|
49
49
|
"tsdown": "^0.18.4"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@arcblock/did": "1.30.
|
|
53
|
-
"@arcblock/did-ext": "1.30.
|
|
54
|
-
"@arcblock/did-util": "1.30.
|
|
52
|
+
"@arcblock/did": "1.30.24",
|
|
53
|
+
"@arcblock/did-ext": "1.30.24",
|
|
54
|
+
"@arcblock/did-util": "1.30.24",
|
|
55
55
|
"@arcblock/nft-display": "^3.2.3",
|
|
56
|
-
"@arcblock/validator": "1.30.
|
|
57
|
-
"@ocap/config": "1.30.
|
|
58
|
-
"@ocap/indexdb": "1.30.
|
|
59
|
-
"@ocap/mcrypto": "1.30.
|
|
60
|
-
"@ocap/message": "1.30.
|
|
61
|
-
"@ocap/state": "1.30.
|
|
62
|
-
"@ocap/tx-protocols": "1.30.
|
|
63
|
-
"@ocap/types": "1.30.
|
|
64
|
-
"@ocap/util": "1.30.
|
|
65
|
-
"@ocap/wallet": "1.30.
|
|
56
|
+
"@arcblock/validator": "1.30.24",
|
|
57
|
+
"@ocap/config": "1.30.24",
|
|
58
|
+
"@ocap/indexdb": "1.30.24",
|
|
59
|
+
"@ocap/mcrypto": "1.30.24",
|
|
60
|
+
"@ocap/message": "1.30.24",
|
|
61
|
+
"@ocap/state": "1.30.24",
|
|
62
|
+
"@ocap/tx-protocols": "1.30.24",
|
|
63
|
+
"@ocap/types": "1.30.24",
|
|
64
|
+
"@ocap/util": "1.30.24",
|
|
65
|
+
"@ocap/wallet": "1.30.24",
|
|
66
66
|
"debug": "^4.4.3",
|
|
67
67
|
"express": "^4.22.1",
|
|
68
68
|
"lodash": "^4.17.23",
|