holepunch-hop 0.3.7 → 0.3.8
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 +87 -5
package/package.json
CHANGED
package/src/bees.js
CHANGED
|
@@ -78,6 +78,15 @@ class HyperBee extends EventEmitter {
|
|
|
78
78
|
await this.dbBentospaces.ready()
|
|
79
79
|
beePubkeys.push({store:'bentospaces', pubkey: b4a.toString(core3.key, 'hex')})
|
|
80
80
|
|
|
81
|
+
const core14 = this.store.get({ name: 'bentochat' })
|
|
82
|
+
this.dbBentochat = new Hyperbee(core14, {
|
|
83
|
+
keyEncoding: 'utf-8', // can be set to undefined (binary), utf-8, ascii or and abstract-encoding
|
|
84
|
+
valueEncoding: 'json' // same options as above
|
|
85
|
+
})
|
|
86
|
+
await this.dbBentochat.ready()
|
|
87
|
+
beePubkeys.push({store:'bentochat', pubkey: b4a.toString(core3.key, 'hex')})
|
|
88
|
+
|
|
89
|
+
|
|
81
90
|
const core4 = this.store.get({ name: 'hopresults' })
|
|
82
91
|
this.dbHOPresults = new Hyperbee(core4, {
|
|
83
92
|
keyEncoding: 'utf-8', // can be set to undefined (binary), utf-8, ascii or and abstract-encoding
|
|
@@ -105,6 +114,13 @@ class HyperBee extends EventEmitter {
|
|
|
105
114
|
await this.dbBentocues.ready()
|
|
106
115
|
beePubkeys.push({store:'bentocues', pubkey: b4a.toString(core7.key, 'hex')})
|
|
107
116
|
|
|
117
|
+
const core13 = this.store.get({ name: 'bentomodels' })
|
|
118
|
+
this.dbBentomodels = new Hyperbee(core13, {
|
|
119
|
+
keyEncoding: 'utf-8', // can be set to undefined (binary), utf-8, ascii or and abstract-encoding
|
|
120
|
+
valueEncoding: 'json' // same options as above
|
|
121
|
+
})
|
|
122
|
+
await this.dbBentomodels.ready()
|
|
123
|
+
beePubkeys.push({store:'bentomodels', pubkey: b4a.toString(core7.key, 'hex')})
|
|
108
124
|
|
|
109
125
|
const core8 = this.store.get({ name: 'bentodecisions' })
|
|
110
126
|
this.dbBentodecisions = new Hyperbee(core8, {
|
|
@@ -149,6 +165,23 @@ class HyperBee extends EventEmitter {
|
|
|
149
165
|
await this.dbBentomedia.ready()
|
|
150
166
|
beePubkeys.push({store:'bentomedia', pubkey: b4a.toString(core12.key, 'hex')})
|
|
151
167
|
|
|
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
|
+
|
|
152
185
|
this.emit('hbee-live')
|
|
153
186
|
// return beePubkeys
|
|
154
187
|
let startBeePubkey = {}
|
|
@@ -211,13 +244,15 @@ class HyperBee extends EventEmitter {
|
|
|
211
244
|
await this.dbHOPresults.put(refContract.hash, refContract.data)
|
|
212
245
|
}
|
|
213
246
|
|
|
247
|
+
/** CHAT */
|
|
248
|
+
|
|
214
249
|
/**
|
|
215
250
|
* save chat history
|
|
216
251
|
* @method saveBentochat
|
|
217
252
|
*
|
|
218
253
|
*/
|
|
219
254
|
saveBentochat = async function (chatHistory) {
|
|
220
|
-
await this.
|
|
255
|
+
await this.dbBentochat.put(chatHistory.chat.chatid, chatHistory)
|
|
221
256
|
let checkSave = await this.getBentochat(chatHistory.chat.chatid)
|
|
222
257
|
return checkSave
|
|
223
258
|
}
|
|
@@ -228,7 +263,7 @@ class HyperBee extends EventEmitter {
|
|
|
228
263
|
*
|
|
229
264
|
*/
|
|
230
265
|
deleteBentochat = async function (chat) {
|
|
231
|
-
await this.
|
|
266
|
+
await this.dbBentochat.del(chat.chatid)
|
|
232
267
|
let deleteInfo = {}
|
|
233
268
|
deleteInfo.chatid = chat.chatid
|
|
234
269
|
return deleteInfo
|
|
@@ -240,8 +275,7 @@ class HyperBee extends EventEmitter {
|
|
|
240
275
|
*
|
|
241
276
|
*/
|
|
242
277
|
getBentochat = async function (key) {
|
|
243
|
-
|
|
244
|
-
const nodeData = await this.dbBentospaces.get(key)
|
|
278
|
+
const nodeData = await this.dbBentochat.get(key)
|
|
245
279
|
return nodeData
|
|
246
280
|
}
|
|
247
281
|
|
|
@@ -251,7 +285,7 @@ class HyperBee extends EventEmitter {
|
|
|
251
285
|
*
|
|
252
286
|
*/
|
|
253
287
|
getBentochatHistory = async function (range) {
|
|
254
|
-
const chathistoryData = this.
|
|
288
|
+
const chathistoryData = this.dbBentochat.createReadStream() // { gt: 'a', lt: 'z' }) // anything >a and <z
|
|
255
289
|
let chatData = []
|
|
256
290
|
for await (const { key, value } of chathistoryData) {
|
|
257
291
|
chatData.push({ key, value })
|
|
@@ -259,6 +293,8 @@ class HyperBee extends EventEmitter {
|
|
|
259
293
|
return chatData
|
|
260
294
|
}
|
|
261
295
|
|
|
296
|
+
/** SPACE */
|
|
297
|
+
|
|
262
298
|
/**
|
|
263
299
|
* save space menu
|
|
264
300
|
* @method saveSpaceHistory
|
|
@@ -365,6 +401,52 @@ class HyperBee extends EventEmitter {
|
|
|
365
401
|
return deleteInfo
|
|
366
402
|
}
|
|
367
403
|
|
|
404
|
+
/** MODELS */
|
|
405
|
+
/**
|
|
406
|
+
* save model
|
|
407
|
+
* @method saveModel
|
|
408
|
+
*/
|
|
409
|
+
saveModel = async function (modelInfo) {
|
|
410
|
+
await this.dbBentomodels.put(modelInfo.id, modelInfo.data)
|
|
411
|
+
let checkSave = await this.getModel(modelInfo.id)
|
|
412
|
+
return checkSave
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* get one cue by id
|
|
417
|
+
* @method getModel
|
|
418
|
+
*
|
|
419
|
+
*/
|
|
420
|
+
getModel = async function (key) {
|
|
421
|
+
const nodeData = await this.dbBentomodels.get(key)
|
|
422
|
+
return nodeData
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* get all cuees
|
|
427
|
+
* @method getModelHistory
|
|
428
|
+
*
|
|
429
|
+
*/
|
|
430
|
+
getModelHistory = async function (key) {
|
|
431
|
+
const modelHistory = await this.dbBentomodels.createReadStream()
|
|
432
|
+
let modelData = []
|
|
433
|
+
for await (const { key, value } of modelHistory) {
|
|
434
|
+
modelData.push({ key, value })
|
|
435
|
+
}
|
|
436
|
+
return modelData
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* delete nxp ref contract from peer library
|
|
441
|
+
* @method deleteBentomodel
|
|
442
|
+
*/
|
|
443
|
+
deleteBentoModel = async function (model) {
|
|
444
|
+
const deleteStatus = await this.dbBentomodels.del(model.id)
|
|
445
|
+
let deleteInfo = {}
|
|
446
|
+
deleteInfo.id = model.id
|
|
447
|
+
return deleteInfo
|
|
448
|
+
}
|
|
449
|
+
|
|
368
450
|
/** MEDIA */
|
|
369
451
|
/**
|
|
370
452
|
* save media
|