trac-msb 0.0.89 → 0.0.91

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.
@@ -1,22 +1,3 @@
1
- e247a9ceefb8a83e28d3c5845055910bc61e0b418c7578d297354708f276af04
2
- 580c44d7827fbeeb7778e4d2dce660b30f3ca3baa4de254ecd556dfb5b60fc35
3
- a3590854889d059927fed4dfdf329b75447bc9f5885b6a843b317d1c2d38258a
4
- dd2f83c9cb1d146c8be6c1d98822cbbb3f631a0659b765c9e4564960acf6e228
5
- 726b2885e551a98c20b37675b113476390f57321768a303e1b6c029ffca509a9
6
- 7da7f48e1c805b551fd69a2b6e59b99c00740dea699c66e10b88bd1efb932815
7
- b54b21197bc35c4c3da4900c39f6c6657ff4d7de03c6da7d5f72b87b26cae108
8
- b1226d4a4d9e44226a69c9109769c2437dfa3f7ee551bfd3e79226dd3c1706e3
9
- 0771f4cb2e3bb22b8f6f91d4c2d0cf83dcef7f20499e773bd940c428caae99e9
10
- 3f6e5959f61c2fca1704dbe03273d03729a7170e1a09515d2cdc302d47771ddd
11
- e74ea17cc6e05f0b09588a70d8573fca63de715a763420ff7e14b68a0c1d1d14
12
- 9dedf2e9f8f63c2ffbdccba6a3e28ace22c3788fbdbcf71b030b8574eeaa92c1
13
- 656c9a53cbed98f9e783b6fd53667a2793c4fd74975cd26971582ea3ab9955f1
14
- 1184e8f926a2f76f12685c9e3fa6b3cd542277ab6c7a09fd02a7391240ceeb18
15
- 744ac7add47923135928bd69a3bf448845338122ece2b9d86b1c53b025028fd1
16
- 7bc277890f992bd006eb0609c61e2c35529baf65765e3e4310f99aa18205a7c6
17
- 8888df74fe541631cedfcf27531d309a02a7915b7680bead4301c342082980b8
18
- e18e2f57285018c8521aee085fdbbb0a69cf2484a9eadd9022cc25913716427a
19
- b97c37985cc087d2512a97e00c3432542a2c874fb31543ba6a0c23ea7758cf39
20
- 0ddf2d7b7144873a2027b784529a9f60d48d0aab859f691faf39fce338e123a2
21
- 73f3dd2bda6d5904570751fad19c251186e04e18acaaf5a893404addcdabd9aa
22
- 5937e8eb2e4a428967ce2866c189fccce23ca1ac9e42ecd195ce8e047d1849b1
1
+ 3e84de76f23d1f8f47aa5f133cb928ead44f91429df0b3f9761205049f2beeec
2
+ bd3c9c5844187407baf418c3aa6329c364297b895f961a1f88a91bfe666f72c2
3
+ 17e1856a71e2aef8be3dcb6776316cf90d339f8cab9bcbb3c356be2da86fd2e7
package/msb.mjs CHANGED
@@ -3,7 +3,7 @@ import {MainSettlementBus} from './src/index.js';
3
3
  const opts = {
4
4
  stores_directory : 'stores/',
5
5
  store_name : typeof process !== "undefined" ? process.argv[2] : Pear.config.args[0],
6
- bootstrap: '07814eb54b2a3ebf61506f056fa1235d11431fcfb6505dccfa880146938093a6',
6
+ bootstrap: '4577ebf1e84c06d48b2caa33fe54ae58be3a79cb30810129d58b725fae412e37',
7
7
  channel: '00axtracnetworkmainsettlementbus',
8
8
  tx : 'axtracnetworkmainsettlementbustx'
9
9
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "trac-msb",
3
3
  "main": "msb.mjs",
4
- "version": "0.0.89",
4
+ "version": "0.0.91",
5
5
  "pear": {
6
6
  "name": "trac-msb",
7
7
  "type": "terminal"
@@ -57,7 +57,7 @@
57
57
  "hypercore": "11.1.2",
58
58
  "hypercore-crypto": "3.4.0",
59
59
  "hyperdht": "^6.20.1",
60
- "hyperswarm": "4.11.1",
60
+ "hyperswarm": "4.11.4",
61
61
  "inspector": "npm:bare-node-inspector",
62
62
  "is-options": "1.0.2",
63
63
  "module": "npm:bare-node-module",
package/src/index.js CHANGED
@@ -382,7 +382,7 @@ export class MainSettlementBus extends ReadyResource {
382
382
  this.#writerEventListener(); // only for writers
383
383
  }
384
384
 
385
- await this.#setUpRoleAutomatically(adminEntry);
385
+ //await this.#setUpRoleAutomatically(adminEntry);
386
386
 
387
387
  if (this.#enable_updater) {
388
388
  this.updater();// TODO: NODE AFTER BECOMING A writer should start the updater
@@ -395,6 +395,7 @@ export class MainSettlementBus extends ReadyResource {
395
395
  }
396
396
 
397
397
  async close() {
398
+ console.log('Closing everything...');
398
399
  if (this.#swarm) {
399
400
  await this.#swarm.destroy();
400
401
  }
@@ -426,10 +427,11 @@ export class MainSettlementBus extends ReadyResource {
426
427
  if (!adminEntry || !message) {
427
428
  return;
428
429
  }
429
- const stream = this.#dht_node.connect(b4a.from(adminEntry.tracPublicKey, 'hex'))
430
+ const node = new DHT({bootstrap:this.#dht_bootstrap})
431
+ const stream = node.connect(b4a.from(adminEntry.tracPublicKey, 'hex'))
430
432
  stream.on('connect', async function () {
431
433
  await stream.send(b4a.from(JSON.stringify({ op : 'add_writer', message : message })));
432
- //await stream.destroy();
434
+ await stream.destroy();
433
435
  });
434
436
  stream.on('open', function () { });
435
437
  stream.on('close', () => { });
package/src/network.js CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  MAX_PEERS,
8
8
  MAX_PARALLEL,
9
9
  MAX_SERVER_CONNECTIONS,
10
+ MAX_CLIENT_CONNECTIONS,
10
11
  OperationType,
11
12
  EntryType
12
13
  } from './utils/constants.js';
@@ -36,7 +37,7 @@ class Network {
36
37
  };
37
38
  }
38
39
 
39
- swarm = new Hyperswarm({ keyPair, bootstrap, maxPeers: MAX_PEERS, maxParallel: MAX_PARALLEL, maxServerConnections: MAX_SERVER_CONNECTIONS });
40
+ swarm = new Hyperswarm({ keyPair, bootstrap : bootstrap, maxPeers: MAX_PEERS, maxParallel: MAX_PARALLEL, maxServerConnections: MAX_SERVER_CONNECTIONS, maxClientConnections : MAX_CLIENT_CONNECTIONS});
40
41
 
41
42
  console.log(`Channel: ${b4a.toString(channel)}`);
42
43
  swarm.on('connection', async (connection) => {
@@ -53,9 +54,16 @@ class Network {
53
54
  }
54
55
  });
55
56
 
56
- swarm.join(channel, { server: true, client: true });
57
+ const discovery = swarm.join(channel, { server: true, client: true });
57
58
  await swarm.flush();
58
- console.log('Joined channel for peer discovery');
59
+ console.log('Joined channel');
60
+ async function refresh(){
61
+ await discovery.refresh();
62
+ setTimeout(function(){
63
+ refresh();
64
+ }, 30_000);
65
+ }
66
+ await refresh();
59
67
  }
60
68
  return swarm;
61
69
  }
@@ -71,9 +79,9 @@ class Network {
71
79
  if(null === msg) return;
72
80
  if(msg === 'get_writer_key'){
73
81
  await connection.send(b4a.from(JSON.stringify({op:'writer_key', key : writingKey})));
74
- //await connection.destroy();
82
+ await connection.destroy();
75
83
  } else if(msg.op !== undefined && msg.message !== undefined && msg.op === 'add_writer'){
76
- //await connection.destroy();
84
+ await connection.destroy();
77
85
  msg = msg.message;
78
86
  const adminEntry = await msb.getSigned(EntryType.ADMIN);
79
87
  if(null === adminEntry || (adminEntry.tracPublicKey !== wallet.publicKey)) return;
@@ -35,9 +35,10 @@ export const MAX_INDEXERS = 3;
35
35
  export const MIN_INDEXERS = 1;
36
36
  export const ACK_INTERVAL = 1000;
37
37
  export const WHITELIST_SLEEP_INTERVAL = 100;
38
- export const MAX_PEERS = 1024;
39
- export const MAX_PARALLEL = 512;
40
- export const MAX_SERVER_CONNECTIONS = 256;
38
+ export const MAX_PEERS = 8;
39
+ export const MAX_PARALLEL = 8;
40
+ export const MAX_SERVER_CONNECTIONS = 4;
41
+ export const MAX_CLIENT_CONNECTIONS = 4;
41
42
  export const UPDATER_INTERVAL = 10_000;
42
43
 
43
44
  const constants = {