trac-msb 0.0.85 → 0.0.86
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/Whitelist/pubkeys.csv +2 -1
- package/package.json +1 -1
- package/src/index.js +5 -2
- package/src/network.js +4 -3
package/Whitelist/pubkeys.csv
CHANGED
|
@@ -11,4 +11,5 @@ b1226d4a4d9e44226a69c9109769c2437dfa3f7ee551bfd3e79226dd3c1706e3
|
|
|
11
11
|
e74ea17cc6e05f0b09588a70d8573fca63de715a763420ff7e14b68a0c1d1d14
|
|
12
12
|
9dedf2e9f8f63c2ffbdccba6a3e28ace22c3788fbdbcf71b030b8574eeaa92c1
|
|
13
13
|
656c9a53cbed98f9e783b6fd53667a2793c4fd74975cd26971582ea3ab9955f1
|
|
14
|
-
1184e8f926a2f76f12685c9e3fa6b3cd542277ab6c7a09fd02a7391240ceeb18
|
|
14
|
+
1184e8f926a2f76f12685c9e3fa6b3cd542277ab6c7a09fd02a7391240ceeb18
|
|
15
|
+
744ac7add47923135928bd69a3bf448845338122ece2b9d86b1c53b025028fd1
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -35,6 +35,7 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
35
35
|
#swarm;
|
|
36
36
|
#dht_server;
|
|
37
37
|
#dht_node;
|
|
38
|
+
#dht_bootstrap;
|
|
38
39
|
#base;
|
|
39
40
|
#writingKey;
|
|
40
41
|
#enable_txchannel;
|
|
@@ -66,7 +67,8 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
66
67
|
this.#store = new Corestore(this.STORES_DIRECTORY + options.store_name);
|
|
67
68
|
this.#bee = null;
|
|
68
69
|
this.#swarm = null;
|
|
69
|
-
this.#
|
|
70
|
+
this.#dht_bootstrap = ['116.202.214.143:10001','116.202.214.149:10001', 'node1.hyperdht.org:49737', 'node2.hyperdht.org:49737', 'node3.hyperdht.org:49737'];
|
|
71
|
+
this.#dht_node = new DHT({ bootstrap: this.#dht_bootstrap });
|
|
70
72
|
this.#dht_server = null;
|
|
71
73
|
this.#base = null;
|
|
72
74
|
this.#writingKey = null;
|
|
@@ -353,7 +355,7 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
353
355
|
console.log('Writer Key:', this.#writingKey);
|
|
354
356
|
|
|
355
357
|
if (this.#replicate) {
|
|
356
|
-
this.#swarm = await Network.replicate(this.#swarm, this.#enable_wallet, this.#store, this.#wallet, this.#channel, this.#isStreaming, this.#handleIncomingEvent.bind(this), this.emit.bind(this));
|
|
358
|
+
this.#swarm = await Network.replicate(this.#dht_bootstrap, this.#swarm, this.#enable_wallet, this.#store, this.#wallet, this.#channel, this.#isStreaming, this.#handleIncomingEvent.bind(this), this.emit.bind(this));
|
|
357
359
|
}
|
|
358
360
|
|
|
359
361
|
if (this.#enable_txchannel) {
|
|
@@ -418,6 +420,7 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
418
420
|
const stream = this.#dht_node.connect(b4a.from(adminEntry.tracPublicKey, 'hex'))
|
|
419
421
|
stream.on('connect', async function () {
|
|
420
422
|
await stream.send(b4a.from(JSON.stringify({ op : 'add_writer', message : message })));
|
|
423
|
+
await stream.destroy();
|
|
421
424
|
});
|
|
422
425
|
stream.on('open', function () { });
|
|
423
426
|
stream.on('close', () => { });
|
package/src/network.js
CHANGED
|
@@ -24,7 +24,7 @@ class Network {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
static async replicate(swarm, walletEnabled, store, wallet, channel, isStreaming, handleIncomingEvent, emit) {
|
|
27
|
+
static async replicate(bootstrap, swarm, walletEnabled, store, wallet, channel, isStreaming, handleIncomingEvent, emit) {
|
|
28
28
|
if (!swarm) {
|
|
29
29
|
let keyPair;
|
|
30
30
|
if (!walletEnabled) {
|
|
@@ -36,7 +36,7 @@ class Network {
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
swarm = new Hyperswarm({ keyPair, maxPeers: MAX_PEERS, maxParallel: MAX_PARALLEL, maxServerConnections: MAX_SERVER_CONNECTIONS });
|
|
39
|
+
swarm = new Hyperswarm({ keyPair, bootstrap, maxPeers: MAX_PEERS, maxParallel: MAX_PARALLEL, maxServerConnections: MAX_SERVER_CONNECTIONS });
|
|
40
40
|
|
|
41
41
|
console.log(`Channel: ${b4a.toString(channel)}`);
|
|
42
42
|
swarm.on('connection', async (connection) => {
|
|
@@ -69,7 +69,9 @@ class Network {
|
|
|
69
69
|
msg = JSON.parse(msg);
|
|
70
70
|
if(msg === 'get_writer_key'){
|
|
71
71
|
await connection.send(b4a.from(JSON.stringify({op:'writer_key', key : writingKey})));
|
|
72
|
+
await connection.destroy();
|
|
72
73
|
} else if(msg.op !== undefined && msg.message !== undefined && msg.op === 'add_writer'){
|
|
74
|
+
await connection.destroy();
|
|
73
75
|
msg = msg.message;
|
|
74
76
|
const adminEntry = await msb.getSigned(EntryType.ADMIN);
|
|
75
77
|
if(null === adminEntry || (adminEntry.tracPublicKey !== wallet.publicKey)) return;
|
|
@@ -118,7 +120,6 @@ class Network {
|
|
|
118
120
|
networkInstance.tx_pool.push({ tx: parsedPreTx.tx, append_tx: append_tx });
|
|
119
121
|
}
|
|
120
122
|
}
|
|
121
|
-
//await connection.destroy();
|
|
122
123
|
}catch(e){
|
|
123
124
|
console.log(e);
|
|
124
125
|
}
|