holepunch-hop 0.5.0 → 0.5.3
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/.vscode/settings.json +0 -0
- package/LICENSE +0 -0
- package/README.md +0 -0
- package/package.json +1 -1
- package/src/adapters/sqliteDatabase.js +0 -0
- package/src/adapters/timeConvertor.js +0 -0
- package/src/index.js +0 -1
- package/src/ledger/kbledger.js +0 -0
- package/src/network/peers.js +0 -0
- package/src/storage/bees.js +121 -8
- package/src/storage/drive.js +27 -2
- package/src/storage/fileParser.js +0 -6
- package/test/datacommands/files/data/jan3-bitcoin.csv +0 -0
- package/test/datacommands/files/large-csv.test.js +0 -0
- package/test/datacommands/files/small-csv.test.js +0 -0
- package/test/datacommands/ledger/save-get-ledger.test.js +0 -0
- package/test/datacommands/results/save-get-results.test.js +0 -0
- package/test/holepunch-initiate.test.js +0 -0
- package/test/large-csv.test.js +0 -0
- package/test/multipers/ten-peers-network.test.js +0 -0
- package/test/setup-bee-holepunch.test.js +0 -0
- package/test/setup-holepunch.test.js +0 -0
- package/test/threepers/peer3-geninvite-after.test.js +0 -0
- package/test/threepers/three-peers.test.js +0 -0
- package/test/threepers/two-then-three.test.js +0 -0
- package/test/twopeers/peerClient-Server.test.js +0 -0
- package/test/twopeers/reconnect-peers.test.js +0 -0
- package/test/twopeers/reconnect-serverthen-conerr.test.js +0 -0
- package/test/twopeers/reconnect-then-conerr.test.js +0 -0
- package/test/twopeers/two-peer-one-disconnect.test.js +0 -0
- package/test/twopeers/two-peer-server-disconnect.test.js +0 -0
- package/vitest.config.js +0 -0
package/.vscode/settings.json
CHANGED
|
File without changes
|
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
package/src/index.js
CHANGED
|
@@ -15,7 +15,6 @@ import Hyperswarm from 'hyperswarm'
|
|
|
15
15
|
import goodbye from 'graceful-goodbye'
|
|
16
16
|
import b4a from 'b4a'
|
|
17
17
|
|
|
18
|
-
// import { Node } from 'hyperbee/lib/messages.js'
|
|
19
18
|
import BeeWorker from './storage/bees.js'
|
|
20
19
|
import DriveWorker from './storage/drive.js'
|
|
21
20
|
import PeerWorker from './network/peers.js'
|
package/src/ledger/kbledger.js
CHANGED
|
File without changes
|
package/src/network/peers.js
CHANGED
|
File without changes
|
package/src/storage/bees.js
CHANGED
|
@@ -89,7 +89,6 @@ class HyperBee extends EventEmitter {
|
|
|
89
89
|
await this.dbBentochat.ready()
|
|
90
90
|
beePubkeys.push({store:'bentochat', privacy: 'private', pubkey: b4a.toString(core14.key, 'hex')})
|
|
91
91
|
|
|
92
|
-
|
|
93
92
|
const core4 = this.store.get({ name: 'hopresults' })
|
|
94
93
|
this.dbHOPresults = new Hyperbee(core4, {
|
|
95
94
|
keyEncoding: 'utf-8', // can be set to undefined (binary), utf-8, ascii or and abstract-encoding
|
|
@@ -100,12 +99,12 @@ class HyperBee extends EventEmitter {
|
|
|
100
99
|
beePubkeys.push({store:'hopresults', privacy: 'private', pubkey: b4a.toString(core4.key, 'hex')})
|
|
101
100
|
|
|
102
101
|
const core5 = this.store.get({ name: 'kbledger' })
|
|
103
|
-
this.
|
|
102
|
+
this.dbCohereceLedger = new Hyperbee(core5, {
|
|
104
103
|
keyEncoding: 'utf-8', // can be set to undefined (binary), utf-8, ascii or and abstract-encoding
|
|
105
104
|
valueEncoding: 'json' // same options as above
|
|
106
105
|
})
|
|
107
|
-
await this.
|
|
108
|
-
// this.client.replicate(this.
|
|
106
|
+
await this.dbCohereceLedger.ready()
|
|
107
|
+
// this.client.replicate(this.dbCohereceLedger.feed)
|
|
109
108
|
beePubkeys.push({store:'kbledger', pubkey: b4a.toString(core5.key, 'hex')})
|
|
110
109
|
// stores of cues, media, research, markers, products/treatments
|
|
111
110
|
|
|
@@ -179,7 +178,24 @@ class HyperBee extends EventEmitter {
|
|
|
179
178
|
})
|
|
180
179
|
await this.dbBentomedia.ready()
|
|
181
180
|
beePubkeys.push({store:'bentomedia', privacy: 'private', pubkey: b4a.toString(core12.key, 'hex')})
|
|
182
|
-
|
|
181
|
+
|
|
182
|
+
const core16 = this.store.get({ name: 'besearch' })
|
|
183
|
+
this.dbBesearch = new Hyperbee(core16, {
|
|
184
|
+
keyEncoding: 'utf-8', // can be set to undefined (binary), utf-8, ascii or and abstract-encoding
|
|
185
|
+
valueEncoding: 'json' // same options as above
|
|
186
|
+
})
|
|
187
|
+
await this.dbBesearch.ready()
|
|
188
|
+
beePubkeys.push({store:'besearch', privacy: 'private', pubkey: b4a.toString(core16.key, 'hex')})
|
|
189
|
+
|
|
190
|
+
const core17 = this.store.get({ name: 'beebeelearn' })
|
|
191
|
+
this.dbBeeBeeLearn = new Hyperbee(core17, {
|
|
192
|
+
keyEncoding: 'utf-8', // can be set to undefined (binary), utf-8, ascii or and abstract-encoding
|
|
193
|
+
valueEncoding: 'json' // same options as above
|
|
194
|
+
})
|
|
195
|
+
await this.dbBeeBeeLearn.ready()
|
|
196
|
+
beePubkeys.push({store:'beebeelearn', privacy: 'public', pubkey: b4a.toString(core17.key, 'hex')})
|
|
197
|
+
|
|
198
|
+
// testing help remove for production
|
|
183
199
|
this.emit('hbee-live')
|
|
184
200
|
// return beePubkeys
|
|
185
201
|
let startBeePubkey = {}
|
|
@@ -726,6 +742,103 @@ class HyperBee extends EventEmitter {
|
|
|
726
742
|
return deleteInfo
|
|
727
743
|
}
|
|
728
744
|
|
|
745
|
+
/** Besearch */
|
|
746
|
+
/**
|
|
747
|
+
* save besearch
|
|
748
|
+
* @method saveBesearch
|
|
749
|
+
*
|
|
750
|
+
*/
|
|
751
|
+
saveBesearch = async function (cuesInfo) {
|
|
752
|
+
await this.dbBesearch.put(cuesInfo.id, cuesInfo.data)
|
|
753
|
+
let checkSave = await this.getBesearch(cuesInfo.id)
|
|
754
|
+
return checkSave
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* get one cue by id
|
|
759
|
+
* @method getBesearch
|
|
760
|
+
*
|
|
761
|
+
*/
|
|
762
|
+
getBesearch = async function (key) {
|
|
763
|
+
const nodeData = await this.dbBesearch.get(key)
|
|
764
|
+
return nodeData
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* get all Besearch
|
|
769
|
+
* @method getBesearchHistory
|
|
770
|
+
*
|
|
771
|
+
*/
|
|
772
|
+
getBesearchHistory = async function (key) {
|
|
773
|
+
const cuesHistory = await this.dbBesearch.createReadStream()
|
|
774
|
+
let cuesData = []
|
|
775
|
+
for await (const { key, value } of cuesHistory) {
|
|
776
|
+
cuesData.push({ key, value })
|
|
777
|
+
}
|
|
778
|
+
return cuesData
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* delete contract
|
|
783
|
+
* @method deleteBentoBesearch
|
|
784
|
+
*/
|
|
785
|
+
deleteBentoBesearch = async function (cue) {
|
|
786
|
+
const deleteStatus = await this.dbBesearch.del(cue.id)
|
|
787
|
+
let deleteInfo = {}
|
|
788
|
+
deleteInfo.spaceid = cue.id
|
|
789
|
+
return deleteInfo
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
/** BEEBEE LEARN via @teach */
|
|
794
|
+
/**
|
|
795
|
+
* save chat history
|
|
796
|
+
* @method saveBeeBeeLearn
|
|
797
|
+
*
|
|
798
|
+
*/
|
|
799
|
+
saveBeeBeeLearn = async function (teachSession) {
|
|
800
|
+
await this.dbBeeBeeLearn.put(teachSession.id, teachSession.session)
|
|
801
|
+
let checkSave = await this.getBeeBeeLearn(teachSession.id)
|
|
802
|
+
return checkSave
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* delete chat item
|
|
807
|
+
* @method deleteBeeBeeLearn
|
|
808
|
+
*
|
|
809
|
+
*/
|
|
810
|
+
deleteBeeBeeLearn = async function (key) {
|
|
811
|
+
await this.dbBeeBeeLearn.del(key)
|
|
812
|
+
let deleteInfo = {}
|
|
813
|
+
deleteInfo.id = key
|
|
814
|
+
return deleteInfo
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* lookup peer teach session layout default
|
|
819
|
+
* @method getBeeBeeLearn
|
|
820
|
+
*
|
|
821
|
+
*/
|
|
822
|
+
getBeeBeeLearn = async function (key) {
|
|
823
|
+
const nodeData = await this.dbBeeBeeLearn.get(key)
|
|
824
|
+
return nodeData
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* lookup range save learn @teach history
|
|
829
|
+
* @method getBeeBeeLearnHistory
|
|
830
|
+
*
|
|
831
|
+
*/
|
|
832
|
+
getBeeBeeLearnHistory = async function (range) {
|
|
833
|
+
const teachHistoryData = this.dbBeeBeeLearn.createReadStream() // { gt: 'a', lt: 'z' }) // anything >a and <z
|
|
834
|
+
let teachData = []
|
|
835
|
+
for await (const { key, value } of teachHistoryData) {
|
|
836
|
+
teachData.push({ key, value })
|
|
837
|
+
}
|
|
838
|
+
return teachData
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
// old solo spaces
|
|
729
842
|
/**
|
|
730
843
|
* save space layout of bentobox
|
|
731
844
|
* @method saveSolospace
|
|
@@ -871,7 +984,7 @@ class HyperBee extends EventEmitter {
|
|
|
871
984
|
*
|
|
872
985
|
*/
|
|
873
986
|
saveKBLentry = async function (ledgerEntry) {
|
|
874
|
-
await this.
|
|
987
|
+
await this.dbCohereceLedger.put(ledgerEntry.data, ledgerEntry.hash)
|
|
875
988
|
}
|
|
876
989
|
|
|
877
990
|
/**
|
|
@@ -880,7 +993,7 @@ class HyperBee extends EventEmitter {
|
|
|
880
993
|
*
|
|
881
994
|
*/
|
|
882
995
|
KBLentries = async function (dataPrint) {
|
|
883
|
-
const nodeData = this.
|
|
996
|
+
const nodeData = this.dbCohereceLedger.createReadStream()
|
|
884
997
|
let ledgerData = []
|
|
885
998
|
for await (const { key, value } of nodeData) {
|
|
886
999
|
ledgerData.push({ key, value })
|
|
@@ -894,7 +1007,7 @@ class HyperBee extends EventEmitter {
|
|
|
894
1007
|
*
|
|
895
1008
|
*/
|
|
896
1009
|
peerLedgerProof = async function (dataPrint) {
|
|
897
|
-
const ledgerData = await this.
|
|
1010
|
+
const ledgerData = await this.dbCohereceLedger.get(dataPrint.resultuuid)
|
|
898
1011
|
return ledgerData
|
|
899
1012
|
}
|
|
900
1013
|
|
package/src/storage/drive.js
CHANGED
|
@@ -135,7 +135,7 @@ class HypDrive extends EventEmitter {
|
|
|
135
135
|
saveCSVfilecontent = async function (fData) {
|
|
136
136
|
// extract header info first
|
|
137
137
|
let headerInfo = this.fileUtility.webCSVparse(fData)
|
|
138
|
-
let hyperdrivePath = 'csv/' + fData.data[0].
|
|
138
|
+
let hyperdrivePath = 'csv/' + fData.data[0].file
|
|
139
139
|
let confirmSave = await this.drive.put(hyperdrivePath, fData.data[0].content)
|
|
140
140
|
let saveStatus = {}
|
|
141
141
|
saveStatus.save = confirmSave
|
|
@@ -341,6 +341,24 @@ class HypDrive extends EventEmitter {
|
|
|
341
341
|
return localFile
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
+
/**
|
|
345
|
+
* CSV rebuidl file and give directory location
|
|
346
|
+
* @method CSVhyperdriveLocalfile
|
|
347
|
+
*
|
|
348
|
+
*/
|
|
349
|
+
CSVhyperdriveLocalfile = async function (path) {
|
|
350
|
+
console.log('hyperdreive----')
|
|
351
|
+
console.log(path)
|
|
352
|
+
// File reads to buffer and recreate file
|
|
353
|
+
// const bufFromGet2 = await this.drive.get(path)
|
|
354
|
+
const { value: entry } = await this.drive.entry(path)
|
|
355
|
+
const blobs = await this.drive.getBlobs()
|
|
356
|
+
const bufFromEntry = await blobs.get(entry.blob)
|
|
357
|
+
let localFile = 'localcsv'
|
|
358
|
+
fs.writeFileSync(localFile, bufFromEntry)
|
|
359
|
+
return localFile
|
|
360
|
+
}
|
|
361
|
+
|
|
344
362
|
/**
|
|
345
363
|
* set file path, read and make sqlite3 connect db
|
|
346
364
|
* @method SQLiteSetup
|
|
@@ -433,7 +451,14 @@ class HypDrive extends EventEmitter {
|
|
|
433
451
|
let parseDate4 = DateTime.local(sampleDate)
|
|
434
452
|
// .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])
|
|
435
453
|
*/
|
|
436
|
-
|
|
454
|
+
let millDate = ''
|
|
455
|
+
if (parseDate0.reason !== 'unparsable' || parseDate0.reason !== 'invalid input') {
|
|
456
|
+
millDate = parseDate0.toMillis()
|
|
457
|
+
} else if (parseDate1.reason !== 'unparsable' || parseDate1.reason !== 'invalid input') {
|
|
458
|
+
millDate = parseDate1.toMillis()
|
|
459
|
+
} else if (parseDate2.reason !== 'unparsable' || parseDate2.reason !== 'invalid input') {
|
|
460
|
+
millDate = parseDate2.toMillis()
|
|
461
|
+
}
|
|
437
462
|
return millDate
|
|
438
463
|
}
|
|
439
464
|
|
|
@@ -162,8 +162,6 @@ 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])
|
|
167
165
|
// match name row number
|
|
168
166
|
let lcounter = 0
|
|
169
167
|
let match = ''
|
|
@@ -180,14 +178,10 @@ FileParser.prototype.TEMPwebCSVparse = function (fData) {
|
|
|
180
178
|
// pairData.timestamp = splitRow[2]
|
|
181
179
|
// pairData.price = splitRow[5]
|
|
182
180
|
// console.log(pairData)
|
|
183
|
-
console.log('looop')
|
|
184
|
-
console.log(splitRow)
|
|
185
181
|
if (splitRow[1] !== undefined) {
|
|
186
182
|
extractCol.push(splitRow[fData.context.id])
|
|
187
183
|
// assume data column for now and parse to mills seconds
|
|
188
184
|
let testCH1 = chrono.parseDate(splitRow[fData.context.timestamp])
|
|
189
|
-
console.log('pare chonon date')
|
|
190
|
-
console.log(testCH1)
|
|
191
185
|
let parseDate = this.convertTime.testDataExtact(testCH1)
|
|
192
186
|
// let parseDate = DateTime.fromISO(splitRow[0])
|
|
193
187
|
// let millDate = parseDate.toMillis()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/test/large-csv.test.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/vitest.config.js
CHANGED
|
File without changes
|