hive-p2p 1.0.5 → 1.0.7
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/core/node.mjs +2 -28
- package/core/parameters.mjs +3 -3
- package/index.mjs +1 -1
- package/package.json +1 -1
package/core/node.mjs
CHANGED
|
@@ -8,31 +8,6 @@ import { Topologist } from './topologist.mjs';
|
|
|
8
8
|
import { CryptoCodex } from './crypto-codex.mjs';
|
|
9
9
|
import { NodeServices } from './node-services.mjs';
|
|
10
10
|
|
|
11
|
-
export class NodeConfig {
|
|
12
|
-
/** @type {Array<string>} */
|
|
13
|
-
bootstraps;
|
|
14
|
-
/** @type {CryptoCodex} */
|
|
15
|
-
cryptoCodex;
|
|
16
|
-
/** @type {boolean} */
|
|
17
|
-
start;
|
|
18
|
-
/** @type {string | undefined} */
|
|
19
|
-
domain;
|
|
20
|
-
/** @type {number | undefined} */
|
|
21
|
-
port;
|
|
22
|
-
/** @type {number} */
|
|
23
|
-
verbose;
|
|
24
|
-
|
|
25
|
-
/** @param {Array<string>} bootstraps @param {CryptoCodex} [cryptoCodex] - Identity of the node; if not provided, a new one will be generated @param {boolean} [start] default: false @param {string} [domain] public node only, ex: 'localhost' @param {number} [port] public node only, ex: 8080 */
|
|
26
|
-
constructor(bootstraps, cryptoCodex, start, domain, port, verbose) {
|
|
27
|
-
this.bootstraps = bootstraps;
|
|
28
|
-
this.cryptoCodex = cryptoCodex;
|
|
29
|
-
this.start = start;
|
|
30
|
-
this.domain = domain;
|
|
31
|
-
this.port = port;
|
|
32
|
-
this.verbose = verbose;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
11
|
export class NodeP2P {
|
|
37
12
|
started = false;
|
|
38
13
|
id; cryptoCodex; verbose; arbiter;
|
|
@@ -121,9 +96,8 @@ export class NodeP2P {
|
|
|
121
96
|
// PUBLIC API
|
|
122
97
|
get publicUrl() { return this.services?.publicUrl; }
|
|
123
98
|
|
|
124
|
-
/** @param {
|
|
125
|
-
static async createNode(
|
|
126
|
-
const { bootstraps, cryptoCodex, start, domain, port, verbose } = config;
|
|
99
|
+
/** @param {Array<string>} bootstraps @param {CryptoCodex} [cryptoCodex] - Identity of the node; if not provided, a new one will be generated @param {boolean} [start] default: false @param {string} [domain] public node only, ex: 'localhost' @param {number} [port] public node only, ex: 8080 */
|
|
100
|
+
static async createNode(bootstraps, cryptoCodex, start = true, domain, port = NODE.SERVICE.PORT, verbose = NODE.DEFAULT_VERBOSE) {
|
|
127
101
|
const codex = cryptoCodex || new CryptoCodex();
|
|
128
102
|
if (!codex.publicKey) await codex.generate(domain ? true : false);
|
|
129
103
|
|
package/core/parameters.mjs
CHANGED
|
@@ -8,8 +8,8 @@ export const CLOCK = Clock.instance;
|
|
|
8
8
|
|
|
9
9
|
export const SIMULATION = {
|
|
10
10
|
// FACILITIES TO SIMULATE NETWORK CONDITIONS AND SCENARIOS
|
|
11
|
-
AVOID_INTERVALS:
|
|
12
|
-
USE_TEST_TRANSPORTS:
|
|
11
|
+
AVOID_INTERVALS: false, // avoid intervals for faster simulation | default: true
|
|
12
|
+
USE_TEST_TRANSPORTS: false, // enable simulation features
|
|
13
13
|
ICE_DELAY: { min: 250, max: 3000 }, // ICE candidates in ms | default: { min: 250, max: 3000 }
|
|
14
14
|
ICE_OFFER_FAILURE_RATE: .2, // default: .2, 20% offer failure
|
|
15
15
|
ICE_ANSWER_FAILURE_RATE: .15, // default: .15, 15% answer failure
|
|
@@ -40,7 +40,7 @@ export const NODE = {
|
|
|
40
40
|
export const IDENTITY = {
|
|
41
41
|
DIFFICULTY: 0, // number of leading CATEGORY_PREFIX in bits for anti-sybil | default: 0(disabled) | RECOMMENDED: 7 | ON APPLY IF ARE_IDS_HEX = TRUE
|
|
42
42
|
ARGON2_MEM: 2**17, // Memory usage in KiB for Argon2 | default: 2**16 = 65_536 (64 MiB) | RECOMMENDED: 2**17 = 131_072 (128 MiB) | ON APPLY IF ARE_IDS_HEX = TRUE
|
|
43
|
-
ARE_IDS_HEX:
|
|
43
|
+
ARE_IDS_HEX: true, // Boolean to indicate if we use hex ids, default: true = hex | false = strings as Bytes (can involve in serialization failures)
|
|
44
44
|
PUBLIC_PREFIX: '0', // Identifier prefix for public nodes | default: '0'
|
|
45
45
|
STANDARD_PREFIX: '1', // Identifier prefix for standard nodes | default: '1'
|
|
46
46
|
ID_LENGTH: 16, // !!EVEN NUMBER ONLY!! length of peer id | default: 16
|
package/index.mjs
CHANGED