holepunch-hop 0.1.8 → 0.1.9
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 +63 -16
- package/src/index.js +1 -1
package/package.json
CHANGED
package/src/bees.js
CHANGED
|
@@ -156,15 +156,62 @@ class HyperBee extends EventEmitter {
|
|
|
156
156
|
await this.dbHOPresults.put(refContract.hash, refContract.data)
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
/**
|
|
160
|
+
* save chat history
|
|
161
|
+
* @method saveBentochat
|
|
162
|
+
*
|
|
163
|
+
*/
|
|
164
|
+
saveBentochat = async function (chatHistory) {
|
|
165
|
+
await this.dbBentospaces.put(chatHistory.chat.chatid, chatHistory)
|
|
166
|
+
let checkSave = await this.getBentochat(chatHistory.chat.chatid)
|
|
167
|
+
return checkSave
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* delete chat item
|
|
172
|
+
* @method deleteBentochat
|
|
173
|
+
*
|
|
174
|
+
*/
|
|
175
|
+
deleteBentochat = async function (chat) {
|
|
176
|
+
await this.dbBentospaces.del(chat.chatid)
|
|
177
|
+
let deleteInfo = {}
|
|
178
|
+
deleteInfo.chatid = chat.chatid
|
|
179
|
+
return deleteInfo
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* lookup peer bentospace layout default
|
|
184
|
+
* @method getBentochat
|
|
185
|
+
*
|
|
186
|
+
*/
|
|
187
|
+
getBentochat = async function (key) {
|
|
188
|
+
// let key = 'startbentospaces'
|
|
189
|
+
const nodeData = await this.dbBentospaces.get(key)
|
|
190
|
+
return nodeData
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* lookup range save chat history
|
|
195
|
+
* @method getBentochatHistory
|
|
196
|
+
*
|
|
197
|
+
*/
|
|
198
|
+
getBentochatHistory = async function (range) {
|
|
199
|
+
const chathistoryData = this.dbBentospaces.createReadStream() // { gt: 'a', lt: 'z' }) // anything >a and <z
|
|
200
|
+
let chatData = []
|
|
201
|
+
for await (const { key, value } of chathistoryData) {
|
|
202
|
+
chatData.push({ key, value })
|
|
203
|
+
}
|
|
204
|
+
return chatData
|
|
205
|
+
}
|
|
206
|
+
|
|
159
207
|
/**
|
|
160
208
|
* save space layout of bentobox
|
|
161
209
|
* @method saveBentospace
|
|
162
210
|
*
|
|
163
211
|
*/
|
|
164
212
|
saveBentospace = async function (spaceContract) {
|
|
165
|
-
|
|
166
|
-
await this.
|
|
167
|
-
let checkSave = await this.getBentospace(key)
|
|
213
|
+
await this.dbBentospaces.put(spaceContract.space.spaceid, spaceContract)
|
|
214
|
+
let checkSave = await this.getBentospace(spaceContract.space.spaceid)
|
|
168
215
|
return checkSave
|
|
169
216
|
}
|
|
170
217
|
|
|
@@ -173,12 +220,23 @@ class HyperBee extends EventEmitter {
|
|
|
173
220
|
* @method getBentospace
|
|
174
221
|
*
|
|
175
222
|
*/
|
|
176
|
-
getBentospace = async function () {
|
|
177
|
-
let key = 'startbentospaces'
|
|
223
|
+
getBentospace = async function (key) {
|
|
178
224
|
const nodeData = await this.dbBentospaces.get(key)
|
|
179
225
|
return nodeData
|
|
180
226
|
}
|
|
181
227
|
|
|
228
|
+
/**
|
|
229
|
+
* delete nxp ref contract from peer library
|
|
230
|
+
* @method deleteBentospace
|
|
231
|
+
*
|
|
232
|
+
*/
|
|
233
|
+
deleteBentospace = async function (space) {
|
|
234
|
+
const deleteStatus = await this.dbBentospaces.del(key)
|
|
235
|
+
let deleteInfo = {}
|
|
236
|
+
deleteInfo.spaceid = space.spaceid
|
|
237
|
+
return deleteInfo
|
|
238
|
+
}
|
|
239
|
+
|
|
182
240
|
/**
|
|
183
241
|
* save space layout of bentobox
|
|
184
242
|
* @method saveSolospace
|
|
@@ -329,17 +387,6 @@ class HyperBee extends EventEmitter {
|
|
|
329
387
|
return deleteInfo
|
|
330
388
|
}
|
|
331
389
|
|
|
332
|
-
/**
|
|
333
|
-
* delete nxp ref contract from peer library
|
|
334
|
-
* @method deleteBentospace
|
|
335
|
-
*
|
|
336
|
-
*/
|
|
337
|
-
deleteBentospace = async function (nxpID) {
|
|
338
|
-
let key = 'startbentospaces'
|
|
339
|
-
const deleteStatus = await this.dbBentospaces.del(key)
|
|
340
|
-
return deleteStatus
|
|
341
|
-
}
|
|
342
|
-
|
|
343
390
|
/**
|
|
344
391
|
* repicate the publiclibrary peer to peer
|
|
345
392
|
* @method replicatePubliclibrary
|
package/src/index.js
CHANGED
|
@@ -99,7 +99,7 @@ class HolepunchWorker extends EventEmitter {
|
|
|
99
99
|
// new warm incoming peer
|
|
100
100
|
this.Peers.on('connect-warm', (data) => {
|
|
101
101
|
let peerId = {}
|
|
102
|
-
peerId.name = ''
|
|
102
|
+
peerId.name = 'new-peer'
|
|
103
103
|
peerId.publickkey = data
|
|
104
104
|
peerId.datastore = ''
|
|
105
105
|
this.warmPeers.push(peerId)
|