trac-msb 0.0.87 → 0.0.88

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.
Files changed (3) hide show
  1. package/msb.mjs +2 -2
  2. package/package.json +1 -1
  3. package/src/index.js +10 -1
package/msb.mjs CHANGED
@@ -4,8 +4,8 @@ const opts = {
4
4
  stores_directory : 'stores/',
5
5
  store_name : typeof process !== "undefined" ? process.argv[2] : Pear.config.args[0],
6
6
  bootstrap: '07814eb54b2a3ebf61506f056fa1235d11431fcfb6505dccfa880146938093a6',
7
- channel: '00ogtracnetworkmainsettlementbus',
8
- tx : 'ogtracnetworkmainsettlementbustx'
7
+ channel: '00axtracnetworkmainsettlementbus',
8
+ tx : 'axtracnetworkmainsettlementbustx'
9
9
  };
10
10
 
11
11
  const msb = new MainSettlementBus(opts);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "trac-msb",
3
3
  "main": "msb.mjs",
4
- "version": "0.0.87",
4
+ "version": "0.0.88",
5
5
  "pear": {
6
6
  "name": "trac-msb",
7
7
  "type": "terminal"
package/src/index.js CHANGED
@@ -226,7 +226,7 @@ export class MainSettlementBus extends ReadyResource {
226
226
  if (null === adminEntry || !this.check.sanitizeAdminAndWritersOperations(op) || !this.#isAdmin(adminEntry.value, node)) return;
227
227
 
228
228
  const isWhitelisted = await this.#isWhitelisted(op.key);
229
- if (!isWhitelisted) return;
229
+ if (!isWhitelisted || op.key !== op.value.pub) return;
230
230
  const isMessageVerifed = await this.#verifyMessage(op.value.sig, op.key, MsgUtils.createMessage(op.key, op.value.wk, op.value.nonce, op.type));
231
231
  if (isMessageVerifed) {
232
232
  await this.#addWriter(op, batch, base);
@@ -238,10 +238,19 @@ export class MainSettlementBus extends ReadyResource {
238
238
  if (nodeEntry === null || !nodeEntry.value.isWriter) {
239
239
  await base.addWriter(b4a.from(op.value.wk, 'hex'), { isIndexer: false })
240
240
  await batch.put(op.key, {
241
+ pub : op.value.pub,
241
242
  wk: op.value.wk,
242
243
  isWriter: true,
243
244
  isIndexer: false
244
245
  });
246
+ let length = await batch.get('wrl');
247
+ if(null === length){
248
+ length = 0;
249
+ } else {
250
+ length = length.value;
251
+ }
252
+ await batch.put('wri/'+length, op.value.pub);
253
+ await batch.put('wrl', length + 1);
245
254
  console.log(`Writer added: ${op.key}:${op.value.wk}`);
246
255
  }
247
256
  }