hive-p2p 1.0.4 → 1.0.6
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 +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,7 +8,7 @@ export const CLOCK = Clock.instance;
|
|
|
8
8
|
|
|
9
9
|
export const SIMULATION = {
|
|
10
10
|
// FACILITIES TO SIMULATE NETWORK CONDITIONS AND SCENARIOS
|
|
11
|
-
AVOID_INTERVALS:
|
|
11
|
+
AVOID_INTERVALS: false, // avoid intervals for faster simulation | default: true
|
|
12
12
|
USE_TEST_TRANSPORTS: true, // 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
|