holepunch-hop 0.4.2 → 0.4.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/bees.js +27 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "holepunch-hop",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "data interface to HOP",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/bees.js CHANGED
@@ -988,7 +988,11 @@ class HyperBee extends EventEmitter {
988
988
  saveRepliatePubLibary = async function (data) {
989
989
  // add board nxp
990
990
  let updatePubLib = this.repPublicHolder[data.discoverykey]
991
- await this.updatePublicLibrary(updatePubLib)
991
+ if (data.library === 'publiclibrary') {
992
+ await this.updatePublicLibrary(updatePubLib)
993
+ } else if (data.library === 'cues') {
994
+ await this.updateCuesLibrary(updatePubLib)
995
+ }
992
996
  this.repPublicHolder[data.discoverykey] = []
993
997
  }
994
998
 
@@ -1028,6 +1032,28 @@ class HyperBee extends EventEmitter {
1028
1032
  return true
1029
1033
  }
1030
1034
 
1035
+ /**
1036
+ * update cues library from replication
1037
+ * @method updateCuesLibrary
1038
+ *
1039
+ */
1040
+ updateCuesLibrary = async function (libContracts) {
1041
+ // save entries required
1042
+ const batch = this.dbPublicLibrary.batch()
1043
+ for (const { key, value } of libContracts) {
1044
+ await batch.put(key, JSON.parse(value))
1045
+ }
1046
+ await batch.flush()
1047
+
1048
+ // check
1049
+ const libUpdatecheck = this.dbBentocues.createReadStream()
1050
+ let libConracts = []
1051
+ for await (const { key, value } of libUpdatecheck) {
1052
+ libConracts.push({ key, value })
1053
+ }
1054
+ return true
1055
+ }
1056
+
1031
1057
  /**
1032
1058
  * repicate the publiclibrary peer to peer
1033
1059
  * @method ryOLD