@kronos-integration/service-swarm 2.0.5 → 3.0.0
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 +1 -1
- package/src/service-swarm.mjs +45 -48
package/package.json
CHANGED
package/src/service-swarm.mjs
CHANGED
|
@@ -21,57 +21,53 @@ export class ServiceSwarm extends Service {
|
|
|
21
21
|
return "swarm";
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
static
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
);
|
|
57
|
-
}
|
|
24
|
+
static attributes = mergeAttributeDefinitions(
|
|
25
|
+
prepareAttributesDefinitions({
|
|
26
|
+
server: {
|
|
27
|
+
needsRestart: true,
|
|
28
|
+
default: false,
|
|
29
|
+
type: "boolean"
|
|
30
|
+
},
|
|
31
|
+
client: {
|
|
32
|
+
needsRestart: true,
|
|
33
|
+
default: false,
|
|
34
|
+
type: "boolean"
|
|
35
|
+
},
|
|
36
|
+
dht: {
|
|
37
|
+
description: "well known dht addresses",
|
|
38
|
+
needsRestart: true,
|
|
39
|
+
type: "object"
|
|
40
|
+
},
|
|
41
|
+
maxPeers: {
|
|
42
|
+
description: "total amount of peers that this peer will connect to",
|
|
43
|
+
default: 10,
|
|
44
|
+
needsRestart: true,
|
|
45
|
+
type: "integer"
|
|
46
|
+
},
|
|
47
|
+
key: {
|
|
48
|
+
description: "topic initial key",
|
|
49
|
+
needsRestart: true,
|
|
50
|
+
private: true,
|
|
51
|
+
type: "string"
|
|
52
|
+
}
|
|
53
|
+
}),
|
|
54
|
+
Service.attributes
|
|
55
|
+
);
|
|
58
56
|
|
|
59
|
-
get topics()
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return this._topics;
|
|
57
|
+
get topics() {
|
|
58
|
+
if (!this._topics) {
|
|
59
|
+
this._topics = new Map();
|
|
60
|
+
}
|
|
61
|
+
return this._topics;
|
|
65
62
|
}
|
|
66
63
|
|
|
67
|
-
get topicsByName()
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this._topicsByName = new Map();
|
|
64
|
+
get topicsByName() {
|
|
65
|
+
if (!this._topicsByName) {
|
|
66
|
+
this._topicsByName = new Map();
|
|
71
67
|
}
|
|
72
68
|
return this._topicsByName;
|
|
73
69
|
}
|
|
74
|
-
|
|
70
|
+
|
|
75
71
|
createTopic(name, options) {
|
|
76
72
|
let topic = this.topicsByName.get(name);
|
|
77
73
|
if (!topic) {
|
|
@@ -102,11 +98,12 @@ export class ServiceSwarm extends Service {
|
|
|
102
98
|
}
|
|
103
99
|
|
|
104
100
|
async _start() {
|
|
105
|
-
const swarm = this.swarm = new Hyperswarm({
|
|
101
|
+
const swarm = (this.swarm = new Hyperswarm({
|
|
106
102
|
dht: this.dht,
|
|
107
|
-
maxPeers: this.maxPeers
|
|
103
|
+
maxPeers: this.maxPeers
|
|
104
|
+
}));
|
|
108
105
|
|
|
109
|
-
|
|
106
|
+
/*
|
|
110
107
|
this.discovery = swarm.join(
|
|
111
108
|
topic,
|
|
112
109
|
? {
|