holepunch-hop 0.4.8 → 0.5.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "holepunch-hop",
3
- "version": "0.4.8",
3
+ "version": "0.5.0",
4
4
  "description": "data interface to HOP",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -25,6 +25,8 @@ class TimeConvertor extends EventEmitter {
25
25
  *
26
26
  */
27
27
  testDataExtact = function (sampleDate) {
28
+ console.log('time adopter')
29
+ console.log(sampleDate)
28
30
  let parseDate0 = DateTime.fromISO(sampleDate)
29
31
  let parseDate1 = DateTime.fromHTTP(sampleDate)
30
32
  let parseDate2 = DateTime.fromJSDate(sampleDate)
@@ -35,6 +37,7 @@ class TimeConvertor extends EventEmitter {
35
37
  // .fromJSDate(sampleDate) // .fromHTTP(sampleDate) // fromFormat(sampleDate, "YYY-MM-DD ") //.fromISO(sampleDate) // or DateTime. fromFormat("23-06-2019", "dd-MM-yyyy") .(splitRow[0])// new Date(splitRow[0])
36
38
  // console.log(parseDate) */
37
39
  let millDate = parseDate2.toMillis()
40
+ console.log(millDate)
38
41
  return millDate
39
42
  }
40
43
 
@@ -87,7 +87,7 @@ class HyperBee extends EventEmitter {
87
87
  valueEncoding: 'json' // same options as above
88
88
  })
89
89
  await this.dbBentochat.ready()
90
- beePubkeys.push({store:'bentochat', privacy: 'private', pubkey: b4a.toString(core3.key, 'hex')})
90
+ beePubkeys.push({store:'bentochat', privacy: 'private', pubkey: b4a.toString(core14.key, 'hex')})
91
91
 
92
92
 
93
93
  const core4 = this.store.get({ name: 'hopresults' })
@@ -130,7 +130,15 @@ class HyperBee extends EventEmitter {
130
130
  valueEncoding: 'json' // same options as above
131
131
  })
132
132
  await this.dbBentomodels.ready()
133
- beePubkeys.push({store:'bentomodels', privacy: 'public', pubkey: b4a.toString(core7.key, 'hex')})
133
+ beePubkeys.push({store:'bentomodels', privacy: 'public', pubkey: b4a.toString(core13.key, 'hex')})
134
+
135
+ const core15 = this.store.get({ name: 'bentoboxes' })
136
+ this.dbBentoBoxes = new Hyperbee(core15, {
137
+ keyEncoding: 'utf-8', // can be set to undefined (binary), utf-8, ascii or and abstract-encoding
138
+ valueEncoding: 'json' // same options as above
139
+ })
140
+ await this.dbBentoBoxes.ready()
141
+ beePubkeys.push({store:'bentoboxes', privacy: 'private', pubkey: b4a.toString(core15.key, 'hex')})
134
142
 
135
143
  const core8 = this.store.get({ name: 'bentodecisions' })
136
144
  this.dbBentodecisions = new Hyperbee(core8, {
@@ -140,7 +148,6 @@ class HyperBee extends EventEmitter {
140
148
  await this.dbBentodecisions.ready()
141
149
  beePubkeys.push({store:'bentodecisions', pubkey: b4a.toString(core8.key, 'hex')})
142
150
 
143
-
144
151
  const core9 = this.store.get({ name: 'bentomarkers' })
145
152
  this.dbBentomarkers = new Hyperbee(core9, {
146
153
  keyEncoding: 'utf-8', // can be set to undefined (binary), utf-8, ascii or and abstract-encoding
@@ -149,7 +156,6 @@ class HyperBee extends EventEmitter {
149
156
  await this.dbBentomarkers.ready()
150
157
  beePubkeys.push({store:'bentomarkers', privacy: 'private', pubkey: b4a.toString(core9.key, 'hex')})
151
158
 
152
-
153
159
  const core10 = this.store.get({ name: 'research' })
154
160
  this.dbBentoresearch = new Hyperbee(core10, {
155
161
  keyEncoding: 'utf-8', // can be set to undefined (binary), utf-8, ascii or and abstract-encoding
@@ -158,7 +164,6 @@ class HyperBee extends EventEmitter {
158
164
  await this.dbBentoresearch.ready()
159
165
  beePubkeys.push({store:'research', privacy: 'public', pubkey: b4a.toString(core10.key, 'hex')})
160
166
 
161
-
162
167
  const core11 = this.store.get({ name: 'bentoproducts' })
163
168
  this.dbBentoproducts = new Hyperbee(core11, {
164
169
  keyEncoding: 'utf-8', // can be set to undefined (binary), utf-8, ascii or and abstract-encoding
@@ -184,17 +189,17 @@ class HyperBee extends EventEmitter {
184
189
  this.liveBees = startBeePubkey
185
190
  this.wsocket.send(JSON.stringify(startBeePubkey))
186
191
  this.activeBees = beePubkeys
187
- }
188
192
 
189
- /**
190
- * save kbledger entry
191
- * @method saveKBLentry
192
- *
193
- */
194
- saveKBLentry = async function (ledgerEntry) {
195
- await this.dbKBledger.put(ledgerEntry.hash, ledgerEntry.data)
193
+ // test list of results
194
+ /* let listResults = await this.peerResults()
195
+ console.log(listResults)
196
+ for (let res of listResults) {
197
+ await this.deleteResultsItem(res.key)
198
+ } */
196
199
  }
197
200
 
201
+ /* HOP query results */
202
+
198
203
  /**
199
204
  * save HOPresults
200
205
  * @method saveHOPresults
@@ -204,6 +209,36 @@ class HyperBee extends EventEmitter {
204
209
  await this.dbHOPresults.put(refContract.hash, refContract.data)
205
210
  }
206
211
 
212
+ peerResults = async function () {
213
+ const nodeData = this.dbHOPresults.createReadStream()
214
+ let resData = []
215
+ for await (const { key, value } of nodeData) {
216
+ resData.push({ key, value })
217
+ }
218
+ return resData
219
+ }
220
+
221
+ /**
222
+ * lookup results per dataprint hash
223
+ * @method peerResultsItem
224
+ *
225
+ */
226
+ peerResultsItem = async function (key) {
227
+ const resultData = await this.dbHOPresults.get(key)
228
+ return resultData
229
+ }
230
+
231
+ /**
232
+ * delete results
233
+ * @method deleteResultsItem
234
+ *
235
+ */
236
+ deleteResultsItem = async function (key) {
237
+ const resultData = await this.dbHOPresults.del(key)
238
+ return resultData
239
+ }
240
+
241
+
207
242
  /** CHAT */
208
243
 
209
244
  /**
@@ -361,6 +396,53 @@ class HyperBee extends EventEmitter {
361
396
  return deleteInfo
362
397
  }
363
398
 
399
+ /** BENTOBOXES */
400
+ /**
401
+ * save model
402
+ * @method saveModel
403
+ */
404
+ saveBentoBox = async function (boxInfo) {
405
+ await this.dbBentoBoxes.put(boxInfo.id, boxInfo.data)
406
+ let checkSave = await this.getBentoBox(boxInfo.id)
407
+ return checkSave
408
+ }
409
+
410
+ /**
411
+ * get one cue by id
412
+ * @method getModel
413
+ *
414
+ */
415
+ getBentoBox = async function (key) {
416
+ const nodeData = await this.dbBentoBoxes.get(key)
417
+ return nodeData
418
+ }
419
+
420
+ /**
421
+ * get all cuees
422
+ * @method getModelHistory
423
+ *
424
+ */
425
+ getBentoBoxHistory = async function (key) {
426
+ const boxHistory = await this.dbBentoBoxes.createReadStream()
427
+ let boxData = []
428
+ for await (const { key, value } of boxHistory) {
429
+ boxData.push({ key, value })
430
+ }
431
+ return boxData
432
+ }
433
+
434
+ /**
435
+ * delete nxp ref contract from peer library
436
+ * @method deleteBentoBox
437
+ */
438
+ deleteBentoBox = async function (box) {
439
+ const deleteStatus = await this.dbBentoBoxes.del(box.id)
440
+ let deleteInfo = {}
441
+ deleteInfo.id = box.id
442
+ return deleteInfo
443
+ }
444
+
445
+
364
446
  /** MODELS */
365
447
  /**
366
448
  * save model
@@ -781,6 +863,16 @@ class HyperBee extends EventEmitter {
781
863
  return moduleData
782
864
  }
783
865
 
866
+ /* COHERENCE LEDGER Knowledge Bundle Ledger */
867
+
868
+ /**
869
+ * save kbledger entry
870
+ * @method saveKBLentry
871
+ *
872
+ */
873
+ saveKBLentry = async function (ledgerEntry) {
874
+ await this.dbKBledger.put(ledgerEntry.data, ledgerEntry.hash)
875
+ }
784
876
 
785
877
  /**
786
878
  * get all kbl entries
@@ -797,30 +889,15 @@ class HyperBee extends EventEmitter {
797
889
  }
798
890
 
799
891
  /**
800
- * lookup specific result UUID
801
- * @method peerResultsItem
802
- *
803
- */
804
- peerResultsItem = async function (dataPrint) {
805
- const resultsData = this.dbKBledger.get(dataPrint.resultuuid)
806
- return resultsData
807
- }
808
-
809
- /**
810
- * lookup specific result UUID
811
- * @method peerResults
892
+ * lookup coherence ledger per results id
893
+ * @method peerLedgerProof
812
894
  *
813
895
  */
814
- peerResults = async function () {
815
- const nodeData = this.dbKBledger.createReadStream()
816
- let resData = []
817
- for await (const { key, value } of nodeData) {
818
- resData.push({ key, value })
819
- }
820
- return resData
896
+ peerLedgerProof = async function (dataPrint) {
897
+ const ledgerData = await this.dbKBledger.get(dataPrint.resultuuid)
898
+ return ledgerData
821
899
  }
822
900
 
823
-
824
901
  /**
825
902
  * get stream data for keystore db
826
903
  * @method getStreamHyperbeeDB
@@ -162,6 +162,8 @@ FileParser.prototype.TEMPwebJSONparse = function (fjData) {
162
162
  *
163
163
  */
164
164
  FileParser.prototype.TEMPwebCSVparse = function (fData) {
165
+ console.log('tem csv file data')
166
+ console.log(fData[0])
165
167
  // match name row number
166
168
  let lcounter = 0
167
169
  let match = ''
@@ -178,10 +180,14 @@ FileParser.prototype.TEMPwebCSVparse = function (fData) {
178
180
  // pairData.timestamp = splitRow[2]
179
181
  // pairData.price = splitRow[5]
180
182
  // console.log(pairData)
183
+ console.log('looop')
184
+ console.log(splitRow)
181
185
  if (splitRow[1] !== undefined) {
182
186
  extractCol.push(splitRow[fData.context.id])
183
187
  // assume data column for now and parse to mills seconds
184
188
  let testCH1 = chrono.parseDate(splitRow[fData.context.timestamp])
189
+ console.log('pare chonon date')
190
+ console.log(testCH1)
185
191
  let parseDate = this.convertTime.testDataExtact(testCH1)
186
192
  // let parseDate = DateTime.fromISO(splitRow[0])
187
193
  // let millDate = parseDate.toMillis()