|
@@ -1,4 +1,5 @@
|
1
|
1
|
const Base = require('cobox-group-base')
|
|
2
|
+const swarm = require('cobox-swarm')
|
2
|
3
|
|
3
|
4
|
module.exports = (storage, address, opts = {}) => (
|
4
|
5
|
new BlindReplicator(storage, address, opts)
|
|
@@ -9,6 +10,25 @@ class BlindReplicator extends Base {
|
9
|
10
|
super(storage, address, opts)
|
10
|
11
|
this._initFeeds(opts)
|
11
|
12
|
this._readyCallback = this.multifeed.ready.bind(this.multifeed)
|
|
13
|
+ this._connection = null
|
|
14
|
+ this._isSwarming = true
|
|
15
|
+ }
|
|
16
|
+
|
|
17
|
+ swarm (opts = {}) {
|
|
18
|
+ this._connection = swarm(this, Object.assign(opts, {
|
|
19
|
+ logger: this.config.logger
|
|
20
|
+ }))
|
|
21
|
+ this._isSwarming = true
|
|
22
|
+ return true
|
|
23
|
+ }
|
|
24
|
+
|
|
25
|
+ unswarm () {
|
|
26
|
+ assert(this._isSwarming, 'already swarming')
|
|
27
|
+ this._connection.leave(this.discoveryKey)
|
|
28
|
+ this._connection.destroy()
|
|
29
|
+ this._connection = null
|
|
30
|
+ this._isSwarming = false
|
|
31
|
+ return true
|
12
|
32
|
}
|
13
|
33
|
|
14
|
34
|
save () {
|