trac-msb 0.0.93 → 0.0.94
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 +12 -13
- package/msb.mjs +1 -0
- package/package.json +1 -1
- package/src/index.js +18 -18
- package/src/network.js +2 -2
- package/src/writerManager.js +2 -2
package/Whitelist/pubkeys.csv
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
1961a27b204d9bf8f1d0483103b3b510ed401d502e0b6b41dce399894f6924f1
|
|
1
|
+
7be749936c803c08467c9ee6c4fa5ac512d3c461251a05a46df37e4b7c3352ae
|
|
2
|
+
d9b32f8954b265286a5003789df96dbd17246aa80327486677f5b5b37fc58472
|
|
3
|
+
06a7d7bae9ae73a46ebcfa9041c64eea1c528c80eadeee74bbe1f15b8bb1985c
|
|
4
|
+
1427ccaa352e379f63e183e9332aacf31d8e0fefae1f85ddf0dc79980c8c0a46
|
|
5
|
+
47277c0a81d47ec173a86007e5b2afc0ce7212f341fccbc61336dda86814a4bf
|
|
6
|
+
55abb6145c03eeb36019fc60a57db374695646e19d37fa97bbbe65a8b448708d
|
|
7
|
+
dbeda3d6d66784d1e8088d3bc2e91be5fb09ad808561e0b25a3eef23f3268e6d
|
|
8
|
+
92d5dc88e86885a03309c9e1bd83d3da696de7326875222cc9a97c3e587c9976
|
|
9
|
+
06facf44678703f96e27c0a0bf5ec1c2073bb0c5b54776bcdaa4d66c1d8cda27
|
|
10
|
+
dba246f800a5e29f561a2bde78c61d520079307fdbfae3a31f958c8ea31f90f9
|
|
11
|
+
dc4d146c11bee90870ade1a7ae5a6bdee84d521998c2b60a6628e064363acd3f
|
|
12
|
+
ccf0fea255e442ebe540213274b9d6e5484140d0db8b545978d404c369c680e9
|
package/msb.mjs
CHANGED
|
@@ -4,6 +4,7 @@ const opts = {
|
|
|
4
4
|
stores_directory : 'stores/',
|
|
5
5
|
store_name : typeof process !== "undefined" ? process.argv[2] : Pear.config.args[0],
|
|
6
6
|
bootstrap: '4577ebf1e84c06d48b2caa33fe54ae58be3a79cb30810129d58b725fae412e37',
|
|
7
|
+
enable_updater : true,
|
|
7
8
|
channel: '00axtracnetworkmainsettlementbus',
|
|
8
9
|
tx : 'axtracnetworkmainsettlementbustx'
|
|
9
10
|
};
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -67,7 +67,7 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
67
67
|
this.#store = new Corestore(this.STORES_DIRECTORY + options.store_name);
|
|
68
68
|
this.#bee = null;
|
|
69
69
|
this.#swarm = null;
|
|
70
|
-
this.#dht_bootstrap = ['116.202.214.143:10001','116.202.214.149:10001', 'node1.hyperdht.org:49737', 'node2.hyperdht.org:49737', 'node3.hyperdht.org:49737'];
|
|
70
|
+
this.#dht_bootstrap = [/*'116.202.214.143:10001','116.202.214.149:10001', */'node1.hyperdht.org:49737', 'node2.hyperdht.org:49737', 'node3.hyperdht.org:49737'];
|
|
71
71
|
this.#dht_node = new DHT({ bootstrap: this.#dht_bootstrap });
|
|
72
72
|
this.#dht_server = null;
|
|
73
73
|
this.#base = null;
|
|
@@ -379,7 +379,7 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
379
379
|
await Network.dhtServer(this, this.#dht_server, this.#base, this.#wallet, this.#writingKey, this.#network);
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
const adminEntry = await this.
|
|
382
|
+
const adminEntry = await this.get(EntryType.ADMIN);
|
|
383
383
|
|
|
384
384
|
if (this.#isAdmin(adminEntry)) {
|
|
385
385
|
this.#shouldListenToAdminEvents = true;
|
|
@@ -391,7 +391,7 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
391
391
|
|
|
392
392
|
//await this.#setUpRoleAutomatically(adminEntry);
|
|
393
393
|
|
|
394
|
-
if (this.#enable_updater) {
|
|
394
|
+
if (this.#enable_updater && this.#base.writable) {
|
|
395
395
|
this.updater();// TODO: NODE AFTER BECOMING A writer should start the updater
|
|
396
396
|
}
|
|
397
397
|
|
|
@@ -501,7 +501,7 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
501
501
|
}
|
|
502
502
|
|
|
503
503
|
async getWhitelistEntry(key) {
|
|
504
|
-
const entry = await this.
|
|
504
|
+
const entry = await this.get(WHITELIST_PREFIX + key);
|
|
505
505
|
return entry
|
|
506
506
|
}
|
|
507
507
|
|
|
@@ -542,7 +542,7 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
542
542
|
});
|
|
543
543
|
|
|
544
544
|
this.#base.on(EventType.WRITABLE, async () => {
|
|
545
|
-
const updatedNodeEntry = await this.
|
|
545
|
+
const updatedNodeEntry = await this.get(this.#wallet.publicKey);
|
|
546
546
|
const canEnableWriterEvents = updatedNodeEntry &&
|
|
547
547
|
updatedNodeEntry.wk === this.#writingKey &&
|
|
548
548
|
!this.#shouldListenToWriterEvents;
|
|
@@ -559,7 +559,7 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
559
559
|
console.log('Current node is unwritable');
|
|
560
560
|
return;
|
|
561
561
|
}
|
|
562
|
-
const updatedNodeEntry = await this.
|
|
562
|
+
const updatedNodeEntry = await this.get(this.#wallet.publicKey);
|
|
563
563
|
const canDisableWriterEvents = updatedNodeEntry &&
|
|
564
564
|
!updatedNodeEntry.isWriter &&
|
|
565
565
|
this.#shouldListenToWriterEvents;
|
|
@@ -586,7 +586,7 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
586
586
|
async #writerEventListener() {
|
|
587
587
|
this.on(EventType.WRITER_EVENT, async (parsedRequest) => {
|
|
588
588
|
if(this.#enable_wallet === false) return;
|
|
589
|
-
const adminEntry = await this.
|
|
589
|
+
const adminEntry = await this.get(EntryType.ADMIN);
|
|
590
590
|
const isEventMessageVerifed = await MsgUtils.verifyEventMessage(parsedRequest, this.#wallet)
|
|
591
591
|
if (adminEntry && adminEntry.tracPublicKey === parsedRequest.key && isEventMessageVerifed) {
|
|
592
592
|
await this.#base.append(parsedRequest);
|
|
@@ -604,7 +604,7 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
604
604
|
|
|
605
605
|
async #handleAdminOperations() {
|
|
606
606
|
//TODO: ADJUST FOR WHITELIST STRUCTURE
|
|
607
|
-
const adminEntry = await this.
|
|
607
|
+
const adminEntry = await this.get(EntryType.ADMIN);
|
|
608
608
|
const addAdminMessage = await MsgUtils.assembleAdminMessage(adminEntry, this.#writingKey, this.#wallet, this.#bootstrap);
|
|
609
609
|
if (!adminEntry && this.#wallet && this.#writingKey && this.#writingKey === this.#bootstrap) {
|
|
610
610
|
await this.#base.append(addAdminMessage);
|
|
@@ -613,7 +613,7 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
613
613
|
for (const conn of this.#swarm.connections) {
|
|
614
614
|
|
|
615
615
|
const remotePublicKeyHex = b4a.from(conn.remotePublicKey).toString('hex');
|
|
616
|
-
const remotePublicKeyEntry = await this.
|
|
616
|
+
const remotePublicKeyEntry = await this.get(remotePublicKeyHex);
|
|
617
617
|
const isWhitelisted = await this.#isWhitelisted(remotePublicKeyHex);
|
|
618
618
|
|
|
619
619
|
if (conn.connected &&
|
|
@@ -632,7 +632,7 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
632
632
|
}
|
|
633
633
|
|
|
634
634
|
setTimeout(async () => {
|
|
635
|
-
const updatedAdminEntry = await this.
|
|
635
|
+
const updatedAdminEntry = await this.get(EntryType.ADMIN);
|
|
636
636
|
if (this.#isAdmin(updatedAdminEntry) && !this.#shouldListenToAdminEvents) {
|
|
637
637
|
this.#shouldListenToAdminEvents = true;
|
|
638
638
|
this.#adminEventListener();
|
|
@@ -643,7 +643,7 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
643
643
|
|
|
644
644
|
async #handleWhitelistOperations() {
|
|
645
645
|
if(this.#enable_wallet === false) return;
|
|
646
|
-
const adminEntry = await this.
|
|
646
|
+
const adminEntry = await this.get(EntryType.ADMIN);
|
|
647
647
|
if (!this.#isAdmin(adminEntry)) return;
|
|
648
648
|
|
|
649
649
|
const assembledWhitelistMessages = await MsgUtils.assembleWhitelistMessages(adminEntry, this.#wallet);
|
|
@@ -675,8 +675,8 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
675
675
|
|
|
676
676
|
async #requestWriterRole(toAdd) {
|
|
677
677
|
if(this.#enable_wallet === false) return;
|
|
678
|
-
const adminEntry = await this.
|
|
679
|
-
const nodeEntry = await this.
|
|
678
|
+
const adminEntry = await this.get(EntryType.ADMIN);
|
|
679
|
+
const nodeEntry = await this.get(this.#wallet.publicKey);
|
|
680
680
|
const isAlreadyWriter = !!(nodeEntry && nodeEntry.isWriter)
|
|
681
681
|
let assembledMessage = null;
|
|
682
682
|
if (toAdd) {
|
|
@@ -699,16 +699,16 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
699
699
|
|
|
700
700
|
async #updateIndexerRole(tracPublicKey, toAdd) {
|
|
701
701
|
if(this.#enable_wallet === false) return;
|
|
702
|
-
const adminEntry = await this.
|
|
702
|
+
const adminEntry = await this.get(EntryType.ADMIN);
|
|
703
703
|
if (!this.#isAdmin(adminEntry) && !this.#base.writable) return;
|
|
704
704
|
|
|
705
705
|
const isWhitelisted = await this.#isWhitelisted(tracPublicKey);
|
|
706
706
|
if (!isWhitelisted) return;
|
|
707
707
|
|
|
708
|
-
const nodeEntry = await this.
|
|
708
|
+
const nodeEntry = await this.get(tracPublicKey);
|
|
709
709
|
if (!nodeEntry || !nodeEntry.isWriter) return;
|
|
710
710
|
|
|
711
|
-
const indexersEntry = await this.
|
|
711
|
+
const indexersEntry = await this.get(EntryType.INDEXERS);
|
|
712
712
|
|
|
713
713
|
if (toAdd) {
|
|
714
714
|
const canAddIndexer = !nodeEntry.isIndexer && indexersEntry.length <= MAX_INDEXERS;
|
|
@@ -791,9 +791,9 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
791
791
|
case '/show':
|
|
792
792
|
// /get_node_info 9da99d98f02f24bdb13d46ba5d346c9a3eda03c18ab6e1441b7bac9743cf0bcc1
|
|
793
793
|
// Only for DEBUG
|
|
794
|
-
const admin = await this.
|
|
794
|
+
const admin = await this.get(EntryType.ADMIN);
|
|
795
795
|
console.log('Admin:', admin);
|
|
796
|
-
const indexers = await this.
|
|
796
|
+
const indexers = await this.get(EntryType.INDEXERS);
|
|
797
797
|
console.log('Indexers:', indexers);
|
|
798
798
|
break;
|
|
799
799
|
case '/dag':
|
package/src/network.js
CHANGED
|
@@ -83,9 +83,9 @@ class Network {
|
|
|
83
83
|
} else if(msg.op !== undefined && msg.message !== undefined && msg.op === 'add_writer'){
|
|
84
84
|
await connection.destroy();
|
|
85
85
|
msg = msg.message;
|
|
86
|
-
const adminEntry = await msb.
|
|
86
|
+
const adminEntry = await msb.get(EntryType.ADMIN);
|
|
87
87
|
if(null === adminEntry || (adminEntry.tracPublicKey !== wallet.publicKey)) return;
|
|
88
|
-
const nodeEntry = await msb.
|
|
88
|
+
const nodeEntry = await msb.get(msg.value.pub);
|
|
89
89
|
const isAlreadyWriter = null !== nodeEntry && nodeEntry.isWriter;
|
|
90
90
|
const isAllowedToRequestRole = await msb._isAllowedToRequestRole(msg.value.pub, adminEntry);
|
|
91
91
|
const canAddWriter = base.writable && !isAlreadyWriter && isAllowedToRequestRole;
|
package/src/writerManager.js
CHANGED
|
@@ -13,7 +13,7 @@ export class WriterManager extends ReadyResource {
|
|
|
13
13
|
|
|
14
14
|
async addAdmin() {
|
|
15
15
|
// case where admin entry doesn't exist yet and we have to autorize Admin public key only with bootstrap writing key
|
|
16
|
-
const adminEntry = await this.msbInstance.
|
|
16
|
+
const adminEntry = await this.msbInstance.get('admin');
|
|
17
17
|
if (!adminEntry && this.msbInstance.writingKey && this.msbInstance.writingKey === this.msbInstance.bootstrap) {
|
|
18
18
|
|
|
19
19
|
const nonce = Math.random() + '-' + Date.now();
|
|
@@ -44,7 +44,7 @@ export class WriterManager extends ReadyResource {
|
|
|
44
44
|
try {
|
|
45
45
|
//TODO: IMPORTANT - IF WE GONNA STORE ~ 2K-10K PUBLIC KEYS IN THE LIST, WE NEED TO SPLIT IT INTO CHUNKS
|
|
46
46
|
// ONE CHUNK WILL BE ~100 PUBLIC KEYS + NONCE + SIG AND ADDITIONAL BYTES < 4096 BYTES. ADMIN WILL NEED TO PERFORM MULTIPLE APPENDS. FOR NOW THIS IS NOT IMPLEMENTED.
|
|
47
|
-
const adminEntry = await this.msbInstance.
|
|
47
|
+
const adminEntry = await this.msbInstance.get('admin');
|
|
48
48
|
|
|
49
49
|
if (adminEntry && this.msbInstance.wallet.publicKey === Buffer.from(adminEntry.tpk.data).toString('hex')) {
|
|
50
50
|
|