trac-msb 0.0.87 → 0.0.89
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/msb.mjs +2 -2
- package/package.json +1 -1
- package/src/index.js +11 -2
- package/src/network.js +5 -3
package/Whitelist/pubkeys.csv
CHANGED
|
@@ -18,4 +18,5 @@ e74ea17cc6e05f0b09588a70d8573fca63de715a763420ff7e14b68a0c1d1d14
|
|
|
18
18
|
e18e2f57285018c8521aee085fdbbb0a69cf2484a9eadd9022cc25913716427a
|
|
19
19
|
b97c37985cc087d2512a97e00c3432542a2c874fb31543ba6a0c23ea7758cf39
|
|
20
20
|
0ddf2d7b7144873a2027b784529a9f60d48d0aab859f691faf39fce338e123a2
|
|
21
|
-
73f3dd2bda6d5904570751fad19c251186e04e18acaaf5a893404addcdabd9aa
|
|
21
|
+
73f3dd2bda6d5904570751fad19c251186e04e18acaaf5a893404addcdabd9aa
|
|
22
|
+
5937e8eb2e4a428967ce2866c189fccce23ca1ac9e42ecd195ce8e047d1849b1
|
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: '
|
|
8
|
-
tx : '
|
|
7
|
+
channel: '00axtracnetworkmainsettlementbus',
|
|
8
|
+
tx : 'axtracnetworkmainsettlementbustx'
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
const msb = new MainSettlementBus(opts);
|
package/package.json
CHANGED
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
|
}
|
|
@@ -420,7 +429,7 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
420
429
|
const stream = this.#dht_node.connect(b4a.from(adminEntry.tracPublicKey, 'hex'))
|
|
421
430
|
stream.on('connect', async function () {
|
|
422
431
|
await stream.send(b4a.from(JSON.stringify({ op : 'add_writer', message : message })));
|
|
423
|
-
await stream.destroy();
|
|
432
|
+
//await stream.destroy();
|
|
424
433
|
});
|
|
425
434
|
stream.on('open', function () { });
|
|
426
435
|
stream.on('close', () => { });
|
package/src/network.js
CHANGED
|
@@ -66,12 +66,14 @@ class Network {
|
|
|
66
66
|
connection.on('message', async (msg) => {
|
|
67
67
|
try{
|
|
68
68
|
msg = b4a.toString(msg, 'utf-8');
|
|
69
|
+
//console.log(msg);
|
|
69
70
|
msg = JSON.parse(msg);
|
|
71
|
+
if(null === msg) return;
|
|
70
72
|
if(msg === 'get_writer_key'){
|
|
71
73
|
await connection.send(b4a.from(JSON.stringify({op:'writer_key', key : writingKey})));
|
|
72
|
-
await connection.destroy();
|
|
74
|
+
//await connection.destroy();
|
|
73
75
|
} else if(msg.op !== undefined && msg.message !== undefined && msg.op === 'add_writer'){
|
|
74
|
-
await connection.destroy();
|
|
76
|
+
//await connection.destroy();
|
|
75
77
|
msg = msg.message;
|
|
76
78
|
const adminEntry = await msb.getSigned(EntryType.ADMIN);
|
|
77
79
|
if(null === adminEntry || (adminEntry.tracPublicKey !== wallet.publicKey)) return;
|
|
@@ -83,7 +85,7 @@ class Network {
|
|
|
83
85
|
await base.append(msg);
|
|
84
86
|
}
|
|
85
87
|
} else {
|
|
86
|
-
await connection.destroy();
|
|
88
|
+
//await connection.destroy();
|
|
87
89
|
if (base.isIndexer || !base.writable) return;
|
|
88
90
|
|
|
89
91
|
// TODO: decide if a tx rejection should be responded with
|