trac-peer 0.0.8 → 0.0.10
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/package.json +2 -2
- package/src/feature.js +3 -1
- package/src/index.js +2 -2
- package/src/protocol.js +4 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trac-peer",
|
|
3
3
|
"main": "src/index.js",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.10",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"autobase": "7.0.45",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"brittle": "3.0.0",
|
|
12
12
|
"corestore": "7.0.22",
|
|
13
13
|
"debounceify": "1.1.0",
|
|
14
|
-
"trac-wallet": "^0.0.
|
|
14
|
+
"trac-wallet": "^0.0.2",
|
|
15
15
|
"hyperbee": "2.23.0",
|
|
16
16
|
"hypercore": "11.0.48",
|
|
17
17
|
"hypercore-crypto": "3.4.0",
|
package/src/feature.js
CHANGED
|
@@ -7,7 +7,9 @@ class Feature {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
async get(key){
|
|
10
|
-
const
|
|
10
|
+
const view_session = this.peer.base.view.checkout(this.peer.base.view.core.signedLength);
|
|
11
|
+
const result = await view_session.get(key);
|
|
12
|
+
await view_session.close();
|
|
11
13
|
if(result === null) return null;
|
|
12
14
|
return result.value;
|
|
13
15
|
}
|
package/src/index.js
CHANGED
|
@@ -354,8 +354,8 @@ export class Peer extends ReadyResource {
|
|
|
354
354
|
await this.close();
|
|
355
355
|
process.exit(0);
|
|
356
356
|
case '/get_keys':
|
|
357
|
-
console.log("Public Key: ", this.wallet.publicKey
|
|
358
|
-
console.log("Secret Key: ", this.wallet.secretKey
|
|
357
|
+
console.log("Public Key: ", this.wallet.publicKey);
|
|
358
|
+
console.log("Secret Key: ", this.wallet.secretKey);
|
|
359
359
|
break;
|
|
360
360
|
default:
|
|
361
361
|
if (input.startsWith('/add_indexer') || input.startsWith('/add_writer')) {
|
package/src/protocol.js
CHANGED
|
@@ -17,7 +17,7 @@ class Protocol{
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
async addFeature(key, feature){
|
|
20
|
-
const pk1 = this.peer.wallet.publicKey
|
|
20
|
+
const pk1 = this.peer.wallet.publicKey;
|
|
21
21
|
const pk2 = await this.base.view.get('admin');
|
|
22
22
|
if(null === pk2 || pk1 !== pk2.value) throw new Error('addFeature(key, feature): Features only allowed for admin.');
|
|
23
23
|
if(typeof this.features[key] !== "undefined") throw new Error('addFeature(key, feature): Feature key exists already.');
|
|
@@ -28,7 +28,8 @@ class Protocol{
|
|
|
28
28
|
async broadcastTransaction(writer, obj){
|
|
29
29
|
if((this.peer.wallet.publicKey !== null &&
|
|
30
30
|
this.peer.wallet.secretKey !== null) &&
|
|
31
|
-
this.base.localWriter !== null &&
|
|
31
|
+
this.base.localWriter !== null &&
|
|
32
|
+
this.tokenized_input !== null)
|
|
32
33
|
{
|
|
33
34
|
this.nonce = Date.now();
|
|
34
35
|
const MSBwriter = writer;
|
|
@@ -47,7 +48,7 @@ class Protocol{
|
|
|
47
48
|
is: signature,
|
|
48
49
|
w: MSBwriter,
|
|
49
50
|
i: this.peer.writerLocalKey,
|
|
50
|
-
ipk: this.peer.wallet.publicKey
|
|
51
|
+
ipk: this.peer.wallet.publicKey,
|
|
51
52
|
ch : content_hash,
|
|
52
53
|
in : this.nonce
|
|
53
54
|
});
|