holepunch-hop 0.4.2 → 0.4.4
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 +33 -1
package/package.json
CHANGED
package/src/bees.js
CHANGED
|
@@ -115,6 +115,12 @@ class HyperBee extends EventEmitter {
|
|
|
115
115
|
})
|
|
116
116
|
await this.dbBentocues.ready()
|
|
117
117
|
beePubkeys.push({store:'bentocues', privacy: 'public', pubkey: b4a.toString(core7.key, 'hex')})
|
|
118
|
+
// open the cues library
|
|
119
|
+
const discoveryCues = this.swarm.join(this.dbBentocues.discoveryKey)
|
|
120
|
+
// Only display the key once the Hyperbee has been announced to the DHT
|
|
121
|
+
discoveryCues.flushed().then(() => {
|
|
122
|
+
console.log('cues library open')
|
|
123
|
+
})
|
|
118
124
|
|
|
119
125
|
const core13 = this.store.get({ name: 'bentomodels' })
|
|
120
126
|
this.dbBentomodels = new Hyperbee(core13, {
|
|
@@ -988,7 +994,11 @@ class HyperBee extends EventEmitter {
|
|
|
988
994
|
saveRepliatePubLibary = async function (data) {
|
|
989
995
|
// add board nxp
|
|
990
996
|
let updatePubLib = this.repPublicHolder[data.discoverykey]
|
|
991
|
-
|
|
997
|
+
if (data.library === 'public') {
|
|
998
|
+
await this.updatePublicLibrary(updatePubLib)
|
|
999
|
+
} else if (data.library === 'cues') {
|
|
1000
|
+
await this.updateCuesLibrary(updatePubLib)
|
|
1001
|
+
}
|
|
992
1002
|
this.repPublicHolder[data.discoverykey] = []
|
|
993
1003
|
}
|
|
994
1004
|
|
|
@@ -1028,6 +1038,28 @@ class HyperBee extends EventEmitter {
|
|
|
1028
1038
|
return true
|
|
1029
1039
|
}
|
|
1030
1040
|
|
|
1041
|
+
/**
|
|
1042
|
+
* update cues library from replication
|
|
1043
|
+
* @method updateCuesLibrary
|
|
1044
|
+
*
|
|
1045
|
+
*/
|
|
1046
|
+
updateCuesLibrary = async function (libContracts) {
|
|
1047
|
+
// save entries required
|
|
1048
|
+
const batch = this.dbBentocues.batch()
|
|
1049
|
+
for (const { key, value } of libContracts) {
|
|
1050
|
+
await batch.put(key, JSON.parse(value))
|
|
1051
|
+
}
|
|
1052
|
+
await batch.flush()
|
|
1053
|
+
|
|
1054
|
+
// check
|
|
1055
|
+
const libUpdatecheck = this.dbBentocues.createReadStream()
|
|
1056
|
+
let libConracts = []
|
|
1057
|
+
for await (const { key, value } of libUpdatecheck) {
|
|
1058
|
+
libConracts.push({ key, value })
|
|
1059
|
+
}
|
|
1060
|
+
return true
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1031
1063
|
/**
|
|
1032
1064
|
* repicate the publiclibrary peer to peer
|
|
1033
1065
|
* @method ryOLD
|