mirror of
https://github.com/PR0M3TH3AN/TORCH.git
synced 2026-11-09 06:12:15 +00:00
Refactor: Extract lock utils and error classifier to reduce file size
- Extracted `PUBLISH_ERROR_CODES`, `PUBLISH_FAILURE_CATEGORIES`, and `classifyPublishError` to `src/lock-error-classifier.mjs`. - Moved `secureRandom` to `src/lock-utils.mjs`. - Updated `src/lock-publisher.mjs` and `src/lock-ops.mjs` to import shared utilities from `src/lock-utils.mjs`. - Reduced `src/lock-publisher.mjs` size significantly (approx. 100 lines) and verified `src/lock-ops.mjs` remains small. - Verified that tests pass and file sizes are reduced. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
2b8a0c3d0d
commit
19a73145b6
5 files changed
+115
-143
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { randomInt } from 'node:crypto';
|
||||
import { todayDateStr, getIsoWeekStr } from './utils.mjs';
|
||||
|
||||
/**
|
||||
@@ -65,3 +66,9 @@ export function relayListLabel(relays) {
|
||||
export function mergeRelayList(primaryRelays, fallbackRelays) {
|
||||
return [...new Set([...primaryRelays, ...fallbackRelays])];
|
||||
}
|
||||
|
||||
const MAX_RANDOM = 281474976710655; // 2**48 - 1
|
||||
|
||||
export function secureRandom() {
|
||||
return randomInt(0, MAX_RANDOM) / MAX_RANDOM;
|
||||
}
|
||||
Reference in new issue
Block a user