trac-msb 0.0.23 → 0.0.25

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 +2 -2
  3. package/src/index.js +5 -11
package/msb.mjs CHANGED
@@ -3,8 +3,8 @@ const opts = {
3
3
  stores_directory : 'stores/',
4
4
  store_name : process.argv[2],
5
5
  bootstrap: '8e192d111aee4a29497f2967a4126fdabc2071dc7885a62a82bdfc97b4e4a2e3',
6
- channel: Buffer.alloc(32).fill('00botracnetworkmainsettlementbus'),
7
- tx : Buffer.alloc(32).fill('botracnetworkmainsettlementbustx')
6
+ channel: Buffer.alloc(32).fill('00bptracnetworkmainsettlementbus'),
7
+ tx : Buffer.alloc(32).fill('bptracnetworkmainsettlementbustx')
8
8
  };
9
9
 
10
10
  const msb = new MainSettlementBus(opts);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "trac-msb",
3
3
  "main": "src/index.js",
4
- "version": "0.0.23",
4
+ "version": "0.0.25",
5
5
  "pear": {
6
6
  "name": "trac-msb",
7
7
  "type": "terminal"
@@ -12,7 +12,7 @@
12
12
  "test": "brittle test/*.test.js"
13
13
  },
14
14
  "dependencies": {
15
- "autobase": "7.0.45",
15
+ "autobase": "7.1.1",
16
16
  "b4a": "1.6.7",
17
17
  "bare-fs": "4.0.1",
18
18
  "brittle": "3.0.0",
package/src/index.js CHANGED
@@ -67,8 +67,8 @@ export class MainSettlementBus extends ReadyResource {
67
67
  if (null === await view.get(op.key) &&
68
68
  sanitizeTransaction(postTx) &&
69
69
  postTx.op === 'post-tx' &&
70
- crypto.verify(Buffer.from(postTx.tx + postTx.in, 'utf-8'), Buffer.from(postTx.is, 'hex'), Buffer.from(postTx.ipk, 'hex')) &&// sender verification
71
- crypto.verify(Buffer.from(postTx.tx + postTx.wn, 'utf-8'), Buffer.from(postTx.ws, 'hex'), Buffer.from(postTx.wp, 'hex')) &&// writer verification
70
+ crypto.verify(Buffer.from(postTx.tx, 'utf-8'), Buffer.from(postTx.is, 'hex'), Buffer.from(postTx.ipk, 'hex')) &&// sender verification
71
+ crypto.verify(Buffer.from(postTx.tx, 'utf-8'), Buffer.from(postTx.ws, 'hex'), Buffer.from(postTx.wp, 'hex')) &&// writer verification
72
72
  Buffer.byteLength(JSON.stringify(postTx)) <= 4096
73
73
  ) {
74
74
  await view.put(op.key, op.value);
@@ -116,9 +116,7 @@ export class MainSettlementBus extends ReadyResource {
116
116
 
117
117
  async updater(){
118
118
  while(true){
119
- if(this.base.writable){
120
- await this.base.append(null);
121
- }
119
+ await this.base.append(null);
122
120
  await this.sleep(10_000);
123
121
  }
124
122
  }
@@ -140,8 +138,6 @@ export class MainSettlementBus extends ReadyResource {
140
138
 
141
139
  connection.on('data', async (msg) => {
142
140
 
143
- console.log(Buffer.byteLength(msg));
144
-
145
141
  if(_this.base.isIndexer) return;
146
142
 
147
143
  // TODO: decide if a tx rejection should be responded with
@@ -158,12 +154,11 @@ export class MainSettlementBus extends ReadyResource {
158
154
 
159
155
  if (sanitizeTransaction(parsedPreTx) &&
160
156
  parsedPreTx.op === 'pre-tx' &&
161
- crypto.verify(Buffer.from(parsedPreTx.tx + parsedPreTx.in, 'utf-8'), Buffer.from(parsedPreTx.is, 'hex'), Buffer.from(parsedPreTx.ipk, 'hex')) &&
157
+ crypto.verify(Buffer.from(parsedPreTx.tx, 'utf-8'), Buffer.from(parsedPreTx.is, 'hex'), Buffer.from(parsedPreTx.ipk, 'hex')) &&
162
158
  parsedPreTx.w === _this.writerLocalKey &&
163
159
  null === await _this.base.view.get(parsedPreTx.tx)
164
160
  ) {
165
- const nonce = Math.random() + '-' + Date.now();
166
- const signature = crypto.sign(Buffer.from(parsedPreTx.tx + nonce, 'utf-8'), Buffer.from(this.wallet.secretKey, 'hex'));
161
+ const signature = crypto.sign(Buffer.from(parsedPreTx.tx, 'utf-8'), Buffer.from(this.wallet.secretKey, 'hex'));
167
162
  const append_tx = {
168
163
  op: 'post-tx',
169
164
  tx: parsedPreTx.tx,
@@ -174,7 +169,6 @@ export class MainSettlementBus extends ReadyResource {
174
169
  ch: parsedPreTx.ch,
175
170
  in: parsedPreTx.in,
176
171
  ws: signature.toString('hex'),
177
- wn : nonce,
178
172
  wp: this.wallet.publicKey,
179
173
  };
180
174
  _this.tx_pool.push({ tx: parsedPreTx.tx, append_tx : append_tx });