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.
- package/Whitelist/pubkeys.csv +1 -1
- package/msb.mjs +1 -2
- package/package.json +1 -1
- package/src/index.js +1 -2
- package/src/network.js +5 -15
package/Whitelist/pubkeys.csv
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
15
|
+
msb.interactiveMode();
|
|
17
16
|
});
|
package/package.json
CHANGED
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 (
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|