holepunch-hop 0.4.0 → 0.4.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/package.json +1 -1
- package/src/bees.js +61 -28
- package/src/drive.js +3 -8
- package/src/index.js +21 -16
- package/src/peers.js +11 -7
package/package.json
CHANGED
package/src/bees.js
CHANGED
|
@@ -21,6 +21,7 @@ class HyperBee extends EventEmitter {
|
|
|
21
21
|
this.swarm = swarm
|
|
22
22
|
this.liveBees = {}
|
|
23
23
|
this.confirmPubLibList = {}
|
|
24
|
+
this.repPublicHolder = {}
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
/**
|
|
@@ -46,12 +47,13 @@ class HyperBee extends EventEmitter {
|
|
|
46
47
|
valueEncoding: 'json' // same options as above
|
|
47
48
|
})
|
|
48
49
|
await this.dbPublicLibrary.ready()
|
|
49
|
-
beePubkeys.push({ store: 'publiclibrary', pubkey: b4a.toString(this.dbPublicLibrary.key, 'hex')})
|
|
50
|
+
beePubkeys.push({ store: 'publiclibrary', privacy: 'public', pubkey: b4a.toString(this.dbPublicLibrary.key, 'hex')})
|
|
50
51
|
// allow other peer access to public library (need to check for DDOS ie over asked)
|
|
51
52
|
// join a topic for network
|
|
52
53
|
const discovery = this.swarm.join(this.dbPublicLibrary.discoveryKey)
|
|
53
54
|
// Only display the key once the Hyperbee has been announced to the DHT
|
|
54
55
|
discovery.flushed().then(() => {
|
|
56
|
+
console.log('public library open')
|
|
55
57
|
})
|
|
56
58
|
|
|
57
59
|
const core2 = this.store.get({ name: 'peerlibrary' })
|
|
@@ -60,7 +62,7 @@ class HyperBee extends EventEmitter {
|
|
|
60
62
|
valueEncoding: 'json' // same options as above
|
|
61
63
|
})
|
|
62
64
|
await this.dbPeerLibrary.ready()
|
|
63
|
-
beePubkeys.push({store:'peerlibrary', pubkey: b4a.toString(core2.key, 'hex')})
|
|
65
|
+
beePubkeys.push({store:'peerlibrary', privacy: 'private', pubkey: b4a.toString(core2.key, 'hex')})
|
|
64
66
|
|
|
65
67
|
const core6 = this.store.get({ name: 'peers' })
|
|
66
68
|
this.dbPeers = new Hyperbee(core6, {
|
|
@@ -68,7 +70,7 @@ class HyperBee extends EventEmitter {
|
|
|
68
70
|
valueEncoding: 'json' // same options as above
|
|
69
71
|
})
|
|
70
72
|
await this.dbPeers.ready()
|
|
71
|
-
beePubkeys.push({store:'peers', pubkey: b4a.toString(core6.key, 'hex')})
|
|
73
|
+
beePubkeys.push({store:'peers', privacy: 'private', pubkey: b4a.toString(core6.key, 'hex')})
|
|
72
74
|
|
|
73
75
|
const core3 = this.store.get({ name: 'bentospaces' })
|
|
74
76
|
this.dbBentospaces = new Hyperbee(core3, {
|
|
@@ -84,7 +86,7 @@ class HyperBee extends EventEmitter {
|
|
|
84
86
|
valueEncoding: 'json' // same options as above
|
|
85
87
|
})
|
|
86
88
|
await this.dbBentochat.ready()
|
|
87
|
-
beePubkeys.push({store:'bentochat', pubkey: b4a.toString(core3.key, 'hex')})
|
|
89
|
+
beePubkeys.push({store:'bentochat', privacy: 'private', pubkey: b4a.toString(core3.key, 'hex')})
|
|
88
90
|
|
|
89
91
|
|
|
90
92
|
const core4 = this.store.get({ name: 'hopresults' })
|
|
@@ -94,7 +96,7 @@ class HyperBee extends EventEmitter {
|
|
|
94
96
|
})
|
|
95
97
|
await this.dbHOPresults.ready()
|
|
96
98
|
// this.client.replicate(this.dbHOPresults.feed)
|
|
97
|
-
beePubkeys.push({store:'hopresults', pubkey: b4a.toString(core4.key, 'hex')})
|
|
99
|
+
beePubkeys.push({store:'hopresults', privacy: 'private', pubkey: b4a.toString(core4.key, 'hex')})
|
|
98
100
|
|
|
99
101
|
const core5 = this.store.get({ name: 'kbledger' })
|
|
100
102
|
this.dbKBledger = new Hyperbee(core5, {
|
|
@@ -112,7 +114,7 @@ class HyperBee extends EventEmitter {
|
|
|
112
114
|
valueEncoding: 'json' // same options as above
|
|
113
115
|
})
|
|
114
116
|
await this.dbBentocues.ready()
|
|
115
|
-
beePubkeys.push({store:'bentocues', pubkey: b4a.toString(core7.key, 'hex')})
|
|
117
|
+
beePubkeys.push({store:'bentocues', privacy: 'public', pubkey: b4a.toString(core7.key, 'hex')})
|
|
116
118
|
|
|
117
119
|
const core13 = this.store.get({ name: 'bentomodels' })
|
|
118
120
|
this.dbBentomodels = new Hyperbee(core13, {
|
|
@@ -120,7 +122,7 @@ class HyperBee extends EventEmitter {
|
|
|
120
122
|
valueEncoding: 'json' // same options as above
|
|
121
123
|
})
|
|
122
124
|
await this.dbBentomodels.ready()
|
|
123
|
-
beePubkeys.push({store:'bentomodels', pubkey: b4a.toString(core7.key, 'hex')})
|
|
125
|
+
beePubkeys.push({store:'bentomodels', privacy: 'public', pubkey: b4a.toString(core7.key, 'hex')})
|
|
124
126
|
|
|
125
127
|
const core8 = this.store.get({ name: 'bentodecisions' })
|
|
126
128
|
this.dbBentodecisions = new Hyperbee(core8, {
|
|
@@ -137,7 +139,7 @@ class HyperBee extends EventEmitter {
|
|
|
137
139
|
valueEncoding: 'json' // same options as above
|
|
138
140
|
})
|
|
139
141
|
await this.dbBentomarkers.ready()
|
|
140
|
-
beePubkeys.push({store:'bentomarkers', pubkey: b4a.toString(core9.key, 'hex')})
|
|
142
|
+
beePubkeys.push({store:'bentomarkers', privacy: 'private', pubkey: b4a.toString(core9.key, 'hex')})
|
|
141
143
|
|
|
142
144
|
|
|
143
145
|
const core10 = this.store.get({ name: 'research' })
|
|
@@ -146,7 +148,7 @@ class HyperBee extends EventEmitter {
|
|
|
146
148
|
valueEncoding: 'json' // same options as above
|
|
147
149
|
})
|
|
148
150
|
await this.dbBentoresearch.ready()
|
|
149
|
-
beePubkeys.push({store:'research', pubkey: b4a.toString(core10.key, 'hex')})
|
|
151
|
+
beePubkeys.push({store:'research', privacy: 'public', pubkey: b4a.toString(core10.key, 'hex')})
|
|
150
152
|
|
|
151
153
|
|
|
152
154
|
const core11 = this.store.get({ name: 'bentoproducts' })
|
|
@@ -155,7 +157,7 @@ class HyperBee extends EventEmitter {
|
|
|
155
157
|
valueEncoding: 'json' // same options as above
|
|
156
158
|
})
|
|
157
159
|
await this.dbBentoproducts.ready()
|
|
158
|
-
beePubkeys.push({store:'bentoproducts', pubkey: b4a.toString(core11.key, 'hex')})
|
|
160
|
+
beePubkeys.push({store:'bentoproducts', privacy: 'private', pubkey: b4a.toString(core11.key, 'hex')})
|
|
159
161
|
|
|
160
162
|
const core12 = this.store.get({ name: 'bentomedia' })
|
|
161
163
|
this.dbBentomedia = new Hyperbee(core12, {
|
|
@@ -163,25 +165,8 @@ class HyperBee extends EventEmitter {
|
|
|
163
165
|
valueEncoding: 'json' // same options as above
|
|
164
166
|
})
|
|
165
167
|
await this.dbBentomedia.ready()
|
|
166
|
-
beePubkeys.push({store:'bentomedia', pubkey: b4a.toString(core12.key, 'hex')})
|
|
168
|
+
beePubkeys.push({store:'bentomedia', privacy: 'private', pubkey: b4a.toString(core12.key, 'hex')})
|
|
167
169
|
|
|
168
|
-
// temp delete agents
|
|
169
|
-
// this.deleteBentoModel({ id: '5e6e36c953b673fe7b2dd06dd773d43feea42a0d'})
|
|
170
|
-
// this.deleteBentoModel({ id: '8439ec4e6d6b89227145da877fffb697b1209d78'})
|
|
171
|
-
// this.deleteBentoModel({ id: 'ba5b7ba40a1dc5c37722c75d29353437e94f805c'})
|
|
172
|
-
|
|
173
|
-
/*this.deleteBentospace({ cueid: '296ce0efc66045c5842707d4652186e440f2fc21'})
|
|
174
|
-
this.deleteBentospace({ cueid: '7baf3109a5b2c5b64981b494984d1bb1fe72f3ba'})
|
|
175
|
-
this.deleteBentospace({ cueid: 'a820ec16b810603b3b1c6458f33d9f36bafdc533'})
|
|
176
|
-
this.deleteBentospace({ cueid: 'b96fa316c2f7eddf9b842da8c9ac2780f36abdff'})
|
|
177
|
-
this.deleteBentospace({ cueid: 'ddd7eb037439f97ead2d1e1be880e58d329ca54b'})
|
|
178
|
-
this.deleteBentospace({ cueid: 's-296ce0efc66045c5842707d4652186e440f2fc21'})
|
|
179
|
-
this.deleteBentospace({ cueid: 's-7baf3109a5b2c5b64981b494984d1bb1fe72f3ba'})
|
|
180
|
-
this.deleteBentospace({ cueid: 's-83dc025c2298b4673f62fbc436d2c1f8dc525fe8'})
|
|
181
|
-
this.deleteBentospace({ cueid: 's-b96fa316c2f7eddf9b842da8c9ac2780f36abdff'}) */
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
170
|
this.emit('hbee-live')
|
|
186
171
|
// return beePubkeys
|
|
187
172
|
let startBeePubkey = {}
|
|
@@ -874,6 +859,42 @@ class HyperBee extends EventEmitter {
|
|
|
874
859
|
*
|
|
875
860
|
*/
|
|
876
861
|
replicatePubliclibrary = async function (dataIn) {
|
|
862
|
+
// create or get the hypercore using the public key supplied as command-line argument
|
|
863
|
+
const coreRep = this.store.get({ key: b4a.from(dataIn.discoverykey, 'hex') })
|
|
864
|
+
|
|
865
|
+
// create a hyperbee instance using the hypercore instance
|
|
866
|
+
const beePlib = new Hyperbee(coreRep, {
|
|
867
|
+
keyEncoding: 'utf-8',
|
|
868
|
+
valueEncoding: 'utf-8'
|
|
869
|
+
})
|
|
870
|
+
|
|
871
|
+
// wait till the hypercore properties to be intialized
|
|
872
|
+
await coreRep.ready()
|
|
873
|
+
|
|
874
|
+
// logging the public key of the hypercore instance
|
|
875
|
+
// console.log('core key here is:', coreRep.key.toString('hex'))
|
|
876
|
+
|
|
877
|
+
// Attempt to connect to peers
|
|
878
|
+
this.swarm.join(coreRep.discoveryKey, { server: false, client: true })
|
|
879
|
+
|
|
880
|
+
await coreRep.update()
|
|
881
|
+
|
|
882
|
+
const nodeData = beePlib.createReadStream()
|
|
883
|
+
let resData = []
|
|
884
|
+
for await (const { key, value } of nodeData) {
|
|
885
|
+
resData.push({ key, value })
|
|
886
|
+
}
|
|
887
|
+
this.repPublicHolder[dataIn.discoverykey] = resData
|
|
888
|
+
// notify peer repliate complete, ask if want save
|
|
889
|
+
this.emit('publib-replicate-notification', { data: { text: 'public library replication complete', publib: dataIn.discoverykey }})
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
/**
|
|
893
|
+
* repicate the publiclibrary peer to peer
|
|
894
|
+
* @method replicateQueryPubliclibrary
|
|
895
|
+
*
|
|
896
|
+
*/
|
|
897
|
+
replicateQueryPubliclibrary = async function (dataIn) {
|
|
877
898
|
// create or get the hypercore using the public key supplied as command-line argument
|
|
878
899
|
const coreRep = this.store.get({ key: b4a.from(dataIn.data.data.datastores, 'hex') })
|
|
879
900
|
|
|
@@ -958,6 +979,18 @@ class HyperBee extends EventEmitter {
|
|
|
958
979
|
return repMessage */
|
|
959
980
|
}
|
|
960
981
|
|
|
982
|
+
|
|
983
|
+
/**
|
|
984
|
+
* look up holder and save data to public library datastore
|
|
985
|
+
* @method saveRepliatePubLibary
|
|
986
|
+
*
|
|
987
|
+
*/
|
|
988
|
+
saveRepliatePubLibary = async function (data) {
|
|
989
|
+
// add board nxp
|
|
990
|
+
let updatePubLib = this.repPublicHolder[data.discoverykey]
|
|
991
|
+
await this.updatePublicLibrary(updatePubLib)
|
|
992
|
+
this.repPublicHolder[data.discoverykey] = []
|
|
993
|
+
}
|
|
961
994
|
|
|
962
995
|
/**
|
|
963
996
|
* peer confirmed add to public library
|
package/src/drive.js
CHANGED
|
@@ -56,9 +56,10 @@ class HypDrive extends EventEmitter {
|
|
|
56
56
|
await this.drive.ready()
|
|
57
57
|
|
|
58
58
|
let startDrivePubkey = {}
|
|
59
|
-
startDrivePubkey.type = '
|
|
59
|
+
startDrivePubkey.type = 'account'
|
|
60
|
+
startDrivePubkey.action = 'drive-pubkey'
|
|
60
61
|
startDrivePubkey.data = b4a.toString(this.drive.key, 'hex')
|
|
61
|
-
|
|
62
|
+
this.wsocket.send(JSON.stringify(startDrivePubkey))
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
|
|
@@ -102,7 +103,6 @@ class HypDrive extends EventEmitter {
|
|
|
102
103
|
// file input management
|
|
103
104
|
// protocol to save original file
|
|
104
105
|
let newPathFile = await this.hyperdriveFilesave(fileData.data[0].type, fileData.data[0].name, fileData.data[0].content)
|
|
105
|
-
|
|
106
106
|
// extract out the headers name for columns
|
|
107
107
|
let headerSet = this.fileUtility.extractCSVHeaderInfo(fileData)
|
|
108
108
|
// csv to JSON convertion HOP protocol standard
|
|
@@ -164,7 +164,6 @@ class HypDrive extends EventEmitter {
|
|
|
164
164
|
return fileResponse
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
|
|
168
167
|
/**
|
|
169
168
|
* blind sqlite lookup of data (maybe restricture no. of rows of data iniitally)
|
|
170
169
|
* @method blindDataSqlite
|
|
@@ -175,7 +174,6 @@ class HypDrive extends EventEmitter {
|
|
|
175
174
|
return parseData
|
|
176
175
|
}
|
|
177
176
|
|
|
178
|
-
|
|
179
177
|
/**
|
|
180
178
|
* save to hyperdrive file
|
|
181
179
|
* @method hyperdriveFilesave
|
|
@@ -213,7 +211,6 @@ class HypDrive extends EventEmitter {
|
|
|
213
211
|
return hyperdrivePath
|
|
214
212
|
}
|
|
215
213
|
|
|
216
|
-
|
|
217
214
|
/**
|
|
218
215
|
* save a stream of file ie. large file
|
|
219
216
|
* @method hyperdriveStreamSave
|
|
@@ -370,7 +367,6 @@ class HypDrive extends EventEmitter {
|
|
|
370
367
|
return summarySQLinfo
|
|
371
368
|
}
|
|
372
369
|
|
|
373
|
-
|
|
374
370
|
/**
|
|
375
371
|
* ask for device tables and info.
|
|
376
372
|
* @method SQLiteDeviceSetup
|
|
@@ -425,7 +421,6 @@ class HypDrive extends EventEmitter {
|
|
|
425
421
|
|
|
426
422
|
}
|
|
427
423
|
|
|
428
|
-
|
|
429
424
|
/**
|
|
430
425
|
* try to match to known time formats
|
|
431
426
|
* @method testDataExtact
|
package/src/index.js
CHANGED
|
@@ -55,10 +55,10 @@ class HolepunchWorker extends EventEmitter {
|
|
|
55
55
|
|
|
56
56
|
this.swarm.on('update', () => {
|
|
57
57
|
// this.Peers.updateListen(data)
|
|
58
|
-
console.log('update-------')
|
|
59
|
-
console.log(this.swarm.connecting)
|
|
60
|
-
console.log(this.swarm.connections.size)
|
|
61
|
-
console.log(this.swarm.peers.size)
|
|
58
|
+
// console.log('update-------')
|
|
59
|
+
// console.log(this.swarm.connecting)
|
|
60
|
+
// console.log(this.swarm.connections.size)
|
|
61
|
+
// console.log(this.swarm.peers.size)
|
|
62
62
|
})
|
|
63
63
|
|
|
64
64
|
|
|
@@ -146,22 +146,26 @@ class HolepunchWorker extends EventEmitter {
|
|
|
146
146
|
// check if bentoboxN1 included?
|
|
147
147
|
if (data.data.data.content.bbn1.publicN1contracts.length > 0) {
|
|
148
148
|
for (let n1Cont of data.data.data.content.bbn1.publicN1contracts) {
|
|
149
|
-
this.BeeData.
|
|
149
|
+
this.BeeData.replicateQueryPubliclibrary({ data: n1Cont })
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
})
|
|
153
153
|
// public library notification
|
|
154
154
|
this.Peers.on('publiclibrarynotification', (data) => {
|
|
155
|
-
this.BeeData.
|
|
155
|
+
this.BeeData.replicateQueryPubliclibrary(data)
|
|
156
156
|
})
|
|
157
157
|
// beebee notifications public
|
|
158
158
|
this.BeeData.on('publibbeebee-notification', (data) => {
|
|
159
159
|
this.emit('beebee-publib-notification', data)
|
|
160
160
|
})
|
|
161
|
+
// public library replicate
|
|
162
|
+
this.BeeData.on('publib-replicate-notification', (data) => {
|
|
163
|
+
this.emit('replicate-publib-notification', data)
|
|
164
|
+
})
|
|
161
165
|
// new warm incoming peer
|
|
162
166
|
this.Peers.on('connect-warm-first', (data) => {
|
|
163
167
|
// check re establishing peer to peer of first time connection?
|
|
164
|
-
let peerInfoName = 'not-matched' //
|
|
168
|
+
let peerInfoName = 'not-matched' // could be mis match or blind/ cold peer accessing public library
|
|
165
169
|
// check role and match codename
|
|
166
170
|
if (data.roletaken === 'server') {
|
|
167
171
|
// not unique info to match on yet.
|
|
@@ -282,17 +286,22 @@ class HolepunchWorker extends EventEmitter {
|
|
|
282
286
|
let peerActionData = this.Peers.peerHolder[message.data.publickey]
|
|
283
287
|
this.Peers.routeDataPath(reEstablishShort.peer.value.livePeerkey, peerActionData.data)
|
|
284
288
|
}
|
|
285
|
-
}
|
|
289
|
+
}
|
|
286
290
|
} else if (message.action === 'retry') {
|
|
287
|
-
console.log('retry')
|
|
288
291
|
let peerDefaults = this.Peers.peerMatchTopic(message.data.key)
|
|
289
292
|
this.Peers.discoveryMatch(message.data.key)
|
|
290
293
|
} else if (message.action === 'peer-closed') {
|
|
291
|
-
console.log('distroy swarm connections')
|
|
292
|
-
console.log(message)
|
|
293
294
|
this.flushConnections()
|
|
294
295
|
await this.swarm.destroy()
|
|
295
|
-
|
|
296
|
+
} else if (message.action === 'replicate-library') {
|
|
297
|
+
// let reEstablishShort = this.Peers.checkConnectivityStatus(message, this.warmPeers, 'invite-replicate')
|
|
298
|
+
if (message.task === 'public-library-replicate') {
|
|
299
|
+
// write message to peer with open public library
|
|
300
|
+
this.BeeData.replicatePubliclibrary(message.data)
|
|
301
|
+
}
|
|
302
|
+
} else if (message.action === 'save-replicate-library') {
|
|
303
|
+
// look up holder and save to public library please
|
|
304
|
+
this.BeeData.saveRepliatePubLibary(message.data)
|
|
296
305
|
}
|
|
297
306
|
}
|
|
298
307
|
|
|
@@ -446,10 +455,6 @@ class HolepunchWorker extends EventEmitter {
|
|
|
446
455
|
*
|
|
447
456
|
*/
|
|
448
457
|
flushConnections = async function () {
|
|
449
|
-
console.log('flush connections')
|
|
450
|
-
console.log(this.swarm.connections.size)
|
|
451
|
-
console.log(this.swarm.connecting)
|
|
452
|
-
console.log(this.swarm.peers.size)
|
|
453
458
|
await this.swarm.flush()
|
|
454
459
|
await Promise.all(Array.from(this.swarm.connections).map(e => e.flush()))
|
|
455
460
|
await new Promise(resolve => setImmediate(resolve))
|
package/src/peers.js
CHANGED
|
@@ -230,7 +230,6 @@ class NetworkPeers extends EventEmitter {
|
|
|
230
230
|
|
|
231
231
|
conn.on('error', data => {
|
|
232
232
|
let connectLivekeys = Object.keys(this.peerConnect)
|
|
233
|
-
// console.log(this.peerNetwork)
|
|
234
233
|
for (let peer of this.peerNetwork) {
|
|
235
234
|
for (let pconn of connectLivekeys) {
|
|
236
235
|
if (peer.value.livePeerkey === pconn) {
|
|
@@ -257,8 +256,8 @@ class NetworkPeers extends EventEmitter {
|
|
|
257
256
|
*
|
|
258
257
|
*/
|
|
259
258
|
updateListen = function (data) {
|
|
260
|
-
console.log('update listen')
|
|
261
|
-
console.log(data)
|
|
259
|
+
// console.log('update listen')
|
|
260
|
+
// console.log(data)
|
|
262
261
|
}
|
|
263
262
|
|
|
264
263
|
/**
|
|
@@ -282,6 +281,8 @@ class NetworkPeers extends EventEmitter {
|
|
|
282
281
|
} else if (dataShareIn.type === 'private-cue-space') {
|
|
283
282
|
this.emit('cuespace-notification', { publickey: peerMatch, data: dataShareIn })
|
|
284
283
|
} else if (dataShareIn.type === 'public-library') {
|
|
284
|
+
console.log('public rep reque arrivee')
|
|
285
|
+
console.log(dataShareIn)
|
|
285
286
|
this.emit('publiclibrarynotification', { publickey: peerMatch, data: dataShareIn })
|
|
286
287
|
} else if (dataShareIn.type === 'peer') {
|
|
287
288
|
} else if (dataShareIn.type === 'peer-codename-inform') {
|
|
@@ -453,7 +454,12 @@ class NetworkPeers extends EventEmitter {
|
|
|
453
454
|
originalKey = savePeer.key
|
|
454
455
|
}
|
|
455
456
|
}
|
|
456
|
-
|
|
457
|
+
// check if first time peer connect
|
|
458
|
+
if (originalKey.length === 0) {
|
|
459
|
+
return currPubKey
|
|
460
|
+
} else {
|
|
461
|
+
return originalKey
|
|
462
|
+
}
|
|
457
463
|
}
|
|
458
464
|
|
|
459
465
|
/**
|
|
@@ -622,7 +628,7 @@ class NetworkPeers extends EventEmitter {
|
|
|
622
628
|
} else if (peerTopeerState.type === 'peer-write') {
|
|
623
629
|
this.Peers.writeTonetwork(peerTopeerState)
|
|
624
630
|
} else if (peerTopeerState.type === 'public-library') {
|
|
625
|
-
this.Peers.writeToPublicLibrary(
|
|
631
|
+
this.Peers.writeToPublicLibrary(livePubkey, peerTopeerState)
|
|
626
632
|
}
|
|
627
633
|
}
|
|
628
634
|
}
|
|
@@ -764,7 +770,6 @@ class NetworkPeers extends EventEmitter {
|
|
|
764
770
|
*
|
|
765
771
|
*/
|
|
766
772
|
topicConnect = async function (peerID, topic) {
|
|
767
|
-
console.log('topic connect')
|
|
768
773
|
// const noisePublicKey = Buffer.alloc(32).fill(topic) // A topic must be 32 bytes
|
|
769
774
|
const noisePublicKey = Buffer.from(topic, 'hex') // must be 32 bytes
|
|
770
775
|
if (noisePublicKey.length === 32) {
|
|
@@ -783,7 +788,6 @@ class NetworkPeers extends EventEmitter {
|
|
|
783
788
|
*
|
|
784
789
|
*/
|
|
785
790
|
topicListen = async function (topic, peerKey) {
|
|
786
|
-
console.log('topic listen')
|
|
787
791
|
// const noisePublicKey = Buffer.alloc(32).fill(topic) // A topic must be 32 bytes
|
|
788
792
|
// let topicKeylive = noisePublicKey.toString('hex')
|
|
789
793
|
const noisePublicKey = Buffer.from(topic, 'hex') // must be 32 bytes
|