trac-msb 0.1.1 → 0.1.2

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 +1 @@
1
- f95bfb8ef84d4cc3ee074765fb1e2a69af846df4309782fc4bc5bb6e18b944f5
1
+ 23cf5527fb3186628e944d007aeeaa3b21297182f027ae2e5afc820ccd72e08b
package/msb.mjs CHANGED
@@ -5,7 +5,6 @@ const opts = {
5
5
  store_name : typeof process !== "undefined" ? process.argv[2] : Pear.config.args[0],
6
6
  bootstrap: '4577ebf1e84c06d48b2caa33fe54ae58be3a79cb30810129d58b725fae412e37',
7
7
  channel: '00axtracnetworkmainsettlementbus',
8
- tx : 'axtracnetworkmainsettlementbustx',
9
8
  enable_updater : true
10
9
  };
11
10
 
@@ -13,5 +12,5 @@ const msb = new MainSettlementBus(opts);
13
12
 
14
13
  msb.ready().then(() => {
15
14
  console.log('MSB is ready.');
16
- try { msb.interactiveMode(); } catch(e) { console.log('Interactive mode not running. Not necessarily an error.') }
15
+ msb.interactiveMode();
17
16
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "trac-msb",
3
3
  "main": "msb.mjs",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "pear": {
6
6
  "name": "trac-msb",
7
7
  "type": "terminal"
package/src/index.js CHANGED
@@ -71,7 +71,6 @@ export class MainSettlementBus extends ReadyResource {
71
71
  this.#KEY_PAIR_PATH = `${this.STORES_DIRECTORY}${options.store_name}/db/keypair.json`
72
72
  this.#bootstrap = options.bootstrap || null;
73
73
  this.#channel = b4a.alloc(32).fill(options.channel) || null;
74
- this.#tx = b4a.alloc(32).fill(options.tx) || null;
75
74
  this.#store = new Corestore(this.STORES_DIRECTORY + options.store_name);
76
75
  this.#bee = null;
77
76
  this.#swarm = null;
@@ -376,7 +375,7 @@ export class MainSettlementBus extends ReadyResource {
376
375
  console.log('Writer Key:', this.#writingKey);
377
376
 
378
377
  if (this.#replicate) {
379
- this.#swarm = await Network.replicate(this, this.#enable_txchannel, this.#base, this.#writingKey, this.#dht_bootstrap, this.#swarm, this.#enable_wallet, this.#store, this.#wallet, this.#channel, this.#isStreaming, this.#handleIncomingEvent.bind(this), this.emit.bind(this));
378
+ this.#swarm = await Network.replicate(this, this.#network, this.#enable_txchannel, this.#base, this.#writingKey, this.#dht_bootstrap, this.#swarm, this.#enable_wallet, this.#store, this.#wallet, this.#channel, this.#isStreaming, this.#handleIncomingEvent.bind(this), this.emit.bind(this));
380
379
  this.#dht_node = this.#swarm.dht;
381
380
  }
382
381
 
package/src/network.js CHANGED
@@ -24,11 +24,9 @@ class Network {
24
24
  }
25
25
 
26
26
 
27
- static async replicate(msb, enable_txchannel, base, writingKey, bootstrap, swarm, walletEnabled, store, wallet, channel, isStreaming, handleIncomingEvent, emit) {
27
+ static async replicate(msb, network, enable_txchannel, base, writingKey, bootstrap, swarm, walletEnabled, store, wallet, channel, isStreaming, handleIncomingEvent, emit) {
28
28
  if (!swarm) {
29
29
 
30
- const _this = this;
31
-
32
30
  let keyPair;
33
31
  if (!walletEnabled) {
34
32
  keyPair = await store.createKeyPair(TRAC_NAMESPACE);
@@ -87,7 +85,7 @@ class Network {
87
85
  if (base.isIndexer || !base.writable) return;
88
86
 
89
87
  // TODO: decide if a tx rejection should be responded with
90
- if (_this.tx_pool.length >= 1000) {
88
+ if (network.tx_pool.length >= 1000) {
91
89
  console.log('pool full');
92
90
  return
93
91
  }
@@ -96,7 +94,7 @@ class Network {
96
94
 
97
95
  const parsedPreTx = msg;
98
96
 
99
- if (_this.check.sanitizePreTx(parsedPreTx) &&
97
+ if (network.check.sanitizePreTx(parsedPreTx) &&
100
98
  wallet.verify(b4a.from(parsedPreTx.is, 'hex'), b4a.from(parsedPreTx.tx + parsedPreTx.in), b4a.from(parsedPreTx.ipk, 'hex')) &&
101
99
  parsedPreTx.wp === wallet.publicKey &&
102
100
  null === await base.view.get(parsedPreTx.tx)
@@ -118,7 +116,7 @@ class Network {
118
116
  wp: wallet.publicKey,
119
117
  wn: nonce
120
118
  };
121
- _this.tx_pool.push({ tx: parsedPreTx.tx, append_tx: append_tx });
119
+ network.tx_pool.push({ tx: parsedPreTx.tx, append_tx: append_tx });
122
120
  }
123
121
  }
124
122
  }catch(e){
@@ -133,16 +131,8 @@ class Network {
133
131
  }
134
132
  });
135
133
 
136
- const discovery = swarm.join(channel, { server: true, client: true });
134
+ swarm.join(channel, { server: true, client: true });
137
135
  await swarm.flush();
138
- console.log('Joined channel');
139
- async function refresh(){
140
- await discovery.refresh();
141
- setTimeout(function(){
142
- refresh();
143
- }, 30_000);
144
- }
145
- await refresh();
146
136
  }
147
137
  return swarm;
148
138
  }